Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent race condition in KeyValueStore.getAutoSavedValue() (#2193)
This was painful to discover the hard way :( Code to test this: ```js const store = await Actor.openKeyValueStore("test", { forceCloud: true }); const key = "something"; const res = await Promise.all([ store.getAutoSavedValue(key, { foo: [] }), new Promise((r) => setTimeout(r, Math.random() * 1000)).then(() => store.getAutoSavedValue(key, { foo: [] }) ), ]); res[0].foo.push("test"); console.log(res); ``` Run this a few times and at some point you will get two different values in the console.log. (Note that it's using `forceCloud` to make `this.GetValue()` run for a little longer.)
- Loading branch information