Repository navigation
Commit d5b4d34
committed
fix(vfs): don't read localStorage during feature detection in Node
Node 26 exposes `localStorage` as a global accessor that emits an
ExperimentalWarning when read - `typeof` included - unless the process was
started with `--localstorage-file`. The existing feature detect reads it at
module evaluation, so simply importing `@typescript/vfs` prints a warning on
Node 26 before any API of the package is called. The surrounding try/catch
does not help: the accessor warns and returns undefined rather than throwing.
Skip the probe entirely in a bare Node process. The only thing the value is
used for is looking up a `DEBUG` key, and in Node `process.env.DEBUG` already
covers that. Hosts that expose both `process` and a DOM (Electron renderers)
still probe as before, as do browsers.
Also folds the `typeof localStorage.getItem === 'function'` guard added in
#3450 into `hasLocalStorage`, where it belongs.
Signed-off-by: C. Spencer Beggs <spencer@beggs.codes>
Claude-Session: https://claude.ai/code/session_01TTDH2nJgCerAnT3DQPSTew1 parent 61332a7 commit d5b4d34
2 files changed
Lines changed: 22 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
20 | 31 | | |
21 | | - | |
22 | | - | |
23 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
24 | 37 | | |
25 | | - | |
26 | | - | |
| 38 | + | |
27 | 39 | | |
28 | 40 | | |
29 | 41 | | |
| |||
0 commit comments