Commit efb1cf6
committed
(fix): resolve AsyncLocalStorage Illegal Invocation errors
- I (and apparently most mst-persist users) don't use localStorage, so
this went undetected for a while until someone reported a bug
- and I finally hit upon it myself when adding tests shortly after,
which added a solid reproduction as well as a blocker on it
- it made localStorage unusable as all of AsyncLocalStorage's calls
would give Illegal Invocation errors
- see https://stackoverflow.com/q/41126149/3431180 for more details
on this error
- using .call did not work, not on
callWithPromise.call(window, ...) nor func.call(window, ...args)
- similarly window.localStorage.func.bind(window) did not work
- so instead used wrapper functions as an alternative that didn't
feel too convoluted
- using window.localStorage[funcKey] in callWithPromise did not
quite feel right, wrapper functions felt better1 parent 6b1dd3b commit efb1cf6
1 file changed
+5
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | | - | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | | - | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | | - | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
0 commit comments