Skip to content

fix(wa-sqlite): terminate shared clients on database drop - #209

Open
marcus-pousette wants to merge 1 commit into
stack/wa-sqlite-materialized-fastpathfrom
fix/wa-sqlite-shared-worker-lifecycle
Open

fix(wa-sqlite): terminate shared clients on database drop#209
marcus-pousette wants to merge 1 commit into
stack/wa-sqlite-materialized-fastpathfrom
fix/wa-sqlite-shared-worker-lifecycle

Conversation

@marcus-pousette

@marcus-pousette marcus-pousette commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Every tab connected to a SharedWorker database uses the same SQLite session. When one client explicitly calls drop(), that database is deleted and the shared session becomes invalid for every connected client—not only the caller.

This PR makes drop() a terminal session boundary. The worker notifies peer clients, rejects their pending calls with a clear dropped-database error, detaches their ports, and allows a later client to open a clean replacement session. It also prunes ports after observable message/send failures and resets the database once the final client closes.

Scope

This handles explicit drop() and failures the SharedWorker can observe. It does not treat refresh or page unload as a drop, and it cannot reliably detect every abrupt tab or process termination. Adding heartbeat/lease-based liveness would be separate work.

Stack

Depends on #163. After merging this PR with a merge commit, retarget #165 to main.

@marcus-pousette marcus-pousette added bug Something isn't working area:sqlite SQLite extension, sqlite-node, wa-sqlite persistence, and migrations area:web Browser, WASM, OPFS, workers, and playground runtime labels Jul 12, 2026
@marcus-pousette
marcus-pousette force-pushed the fix/wa-sqlite-shared-worker-lifecycle branch from ea62da3 to dc51f82 Compare July 13, 2026 14:31
@marcus-pousette
marcus-pousette force-pushed the stack/wa-sqlite-materialized-fastpath branch from d61997c to f8be4fe Compare July 14, 2026 20:37
@marcus-pousette
marcus-pousette force-pushed the fix/wa-sqlite-shared-worker-lifecycle branch from dc51f82 to 16ca00c Compare July 14, 2026 20:43
@marcus-pousette
marcus-pousette force-pushed the fix/wa-sqlite-shared-worker-lifecycle branch from 16ca00c to fe1ffde Compare July 15, 2026 06:45
@marcus-pousette
marcus-pousette force-pushed the stack/wa-sqlite-materialized-fastpath branch 2 times, most recently from 5b6831f to 6a918bb Compare July 15, 2026 07:16
@marcus-pousette
marcus-pousette force-pushed the fix/wa-sqlite-shared-worker-lifecycle branch from fe1ffde to 102b54a Compare July 15, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:sqlite SQLite extension, sqlite-node, wa-sqlite persistence, and migrations area:web Browser, WASM, OPFS, workers, and playground runtime bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant