Local storage data synchronization problem

I have a serious problem when using local storage, that is, the data will be out of sync.
Here is my code section, please import it directly.
LSTest.json (7.3 KB)
Every time I run the code I get a different result than what I expected, you can check the value stored in the local storage in the state field.

But if I am using local storage directly in the browser, this should not be a problem at all.

localStorage.clear();
let value;
value = `${localStorage.value}`;
console.log(value);
localStorage.setItem('value',Math.random());
value = `${localStorage.value}`;
console.log(value);
localStorage.setItem('value',Math.random());
value = `${localStorage.value}`;
console.log(value);

It's confusing, right?! What you need is to await the setValue and check the box in your query that says keep variables in sync
localstoragetest.json (7.6 KB)

syncvars

Thank you, the problem with the "computer" is now solved.
But on my phone, if I use localStorage.setValue in JS query and then read localStorage.values.foo in Restful query, the data is not read.
The same app works fine on my computer but not on my phone as I want it to, I'm not sure why.