Skip to content

fix(desktop): restore jsdom's localStorage on Node 25/26 - #334

Open
raymondginger2018-sudo wants to merge 1 commit into
HKUDS:mainfrom
raymondginger2018-sudo:pr/desktop-node-webstorage
Open

raymondginger2018-sudo wants to merge 1 commit into
HKUDS:mainfrom
raymondginger2018-sudo:pr/desktop-node-webstorage

Conversation

@raymondginger2018-sudo

Copy link
Copy Markdown
Contributor

Summary

On Node 25 and 26, globalThis.localStorage exists for Web Storage: a method-less stub on 25, and undefined on 26 ("not available because --localstorage-file was not provided"). Vitest's jsdom environment only installs globals that are absent, so jsdom's real Storage never lands and every test that calls localStorage.clear() in beforeEach throws.

Passing --no-experimental-webstorage to the test workers leaves the key absent, so jsdom installs its own. The flag exists on Node 22 (the CI version), where Web Storage is already off, so it is a no-op there.

Changes

  • desktop/vite.config.ts — test.execArgv: ["--no-experimental-webstorage"], with the version rationale in a comment.

Compatibility

  • Node 22 CI: unchanged behaviour (the feature is off; the flag is accepted).
  • Node 25/26: jsdom's localStorage works again; the suite no longer depends on --localstorage-file.
  • No application code, dependency, or build output changes.

Tests

vitest run → 63 files / 440 tests passed on Node 25.2.1; tsc --noEmit and eslint . clean. The same suite fails 108 tests on Node 25 without the flag (that is the bug this fixes).

Node 25 and 26 define a global `localStorage` for Web Storage: a method-less
stub on 25, and `undefined` on 26 ("not available because --localstorage-file
was not provided"). The key exists either way, and Vitest's jsdom environment
only installs globals that are absent, so jsdom's real Storage never lands and
`localStorage.clear()` throws in `beforeEach`.

Passing `--no-experimental-webstorage` to the test workers leaves the key
absent, so jsdom fills it. The flag exists on Node 22 (CI), where Web Storage is
already off, so it is a no-op there.

Tests: `vitest run` 440 passed on Node 25.2.1; `tsc --noEmit` and `eslint .`
clean.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant