setIn behavior when overwriting existing value


I was not staring at the mystery block of code with enough focus and brainpower. It had some incorrect and conditional logic that was running when it should not have been running and one of the side-effects of that was to overwrite the translated strings with english. Since I had turned off the particular feature I was not paying any attention to the code that made it work. :nerd_face:

(original message)

I am seeing strange behavior:

I execute the following:

    console.log("here 3: ",xlated);
    await ephemeral_lcliz_cache.setIn([tk, locale_id.value], xlated);
    console.log("here 4: ",ephemeral_lcliz_cache.value[tk]?.[locale_id.value]);

And the console.log shows this:

here 3: parcourir le portefeuille
here 4: browse the portfolio

More detail:

  1. xlated contains a french string.
  2. PRIOR to the execution of await ephemeral_lcliz_cache.setIn the value of ephemeral_lcliz_cache.value[tk]?.[locale_id.value] is the english string.

The setIn appears to have no effect. This code had been working when, prior to a setIn, the variable ephemeral_lcliz_cache did not contain any existing value for the key pair [tk].[locale_id.value].

Is there some problem with replacing an existing variable element? This is what the data structure looks like:

Further odd behavior.

Staring at the code I decided that a block which followed the above logic might, somehow, rewrite the values back to english. So I commented the block out, ran another test and got the same incorrect results (as far as console.log reported). But then...poking at the data structure in the State tab of the Debug console...I noticed the strings were now correct! :roll_eyes:

This was surprising as I could not see anything suspicious in the code I removed. But there it was. Removing those lines "fixed" the problem.

I then inserted the code back and ran one more test to confirm those lines of code were breaking things, and to begin to study them more carefully. Lo and behold whole function still worked.

As of now I have not been able to reproduce the initial failure. I did not close/reopen the IDE at any point in this process. Nor did I edit any Preloaded JS that might cause a "restart" sort of event.