Commit 0b9c451
fix: lazy-load storage cache on set() to prevent null spread (#38)
When an MV3 service worker wakes up and calls set() with an updater
(e.g. requestStorage.addEvent spreading prev into a new array), the
in-memory cache may still be null because _getDataFromStorage() is
async. The updater then runs with prev = null and [...null] throws
"TypeError: a is not iterable", aborting addEvent and leaving the
approval flow in a bad state (popup opens for a request that was
never persisted).
Load the cache synchronously-ish (await from chrome.storage) in set()
if it's still null, so every updater receives a real value.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 78b5ca0 commit 0b9c451
1 file changed
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
171 | 174 | | |
172 | 175 | | |
173 | 176 | | |
| |||
0 commit comments