Skip to content

Use IndexedDB in a Web Worker: detect the browser on indexedDB, not window - #178

Merged
pietercolpaert merged 1 commit into
mainfrom
fix-177-web-worker
Nov 18, 2026
Merged

pietercolpaert merged 1 commit into
mainfrom
fix-177-web-worker

Conversation

@pietercolpaert

Copy link
Copy Markdown
Member

LevelStorage chose between the browser and Node.js on typeof window. A Web Worker has no window, so the client took the Node.js path there and called os.tmpdir() or fs.existsSync(), which are empty modules in the browser build: every replication in a worker failed. Decide on typeof indexedDB instead, and add a browser test that replicates in a Worker with and without a statePath.

Fixes #177

…indow

LevelStorage chose between the browser and Node.js on `typeof window`.
A Web Worker has no `window`, so the client took the Node.js path there
and called `os.tmpdir()` or `fs.existsSync()`, which are empty modules in
the browser build: every replication in a worker failed. Decide on
`typeof indexedDB` instead, and add a browser test that replicates in a
Worker with and without a statePath.

Fixes #177

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pietercolpaert
pietercolpaert merged commit ac5f704 into main Nov 18, 2026
7 checks passed
@pietercolpaert
pietercolpaert deleted the fix-177-web-worker branch November 18, 2026 15:23
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.

LevelStorage detects the browser with typeof window, so the client fails in a Web Worker

1 participant