Is there an order guarantee between the storage.set() and a following storage.get(), or storage.get() will always get the storage area ignoring other storage.set() method?

config1: {
“captchaUrl”: “://”,
“content_script”: “site.js”
}); => {
let config2=settings[“config1”];
// block02, do something with config here

Is it guaranteed that the config2 would always get an object rather than undefined?? Or is there an order guarantee that the the storage.get() method above will get the data set by the storage.set() which is followed by storage.get() ?
I have made a test but I coundn’t find any documentation about this.

(Axel) #2

StorageArea.set is async, so no.


async means that StorageArea.set will not block, and the real storing action will work in the background, then the will be executed immediately, and the real retrieving action will also work in the background. After the real work in the background, both callbacks in then() method will get invoked.
Is the order between the real storing action and the real retrieving action also not guaranteed??

(Martin Giger) #4

No, there is no guarantee of order. Current behavior may have ordering, but that is no API guarantee.

If you need them to happen in order, wait for set until you get again.


:ok_hand:Thanks for your answers.