Commit e340e2b
authored
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.)1 parent a2d7f49 commit e340e2b
1 file changed
+9
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
230 | 239 | | |
231 | 240 | | |
232 | 241 | | |
| |||
0 commit comments