Skip to content

feat(client): SharedWorker support in the event transport - #4

Merged
Alex-Dolid merged 1 commit into
feature/v2from
feature/shared-worker
Sep 15, 2026
Merged

Alex-Dolid merged 1 commit into
feature/v2from
feature/shared-worker

Conversation

@Alex-Dolid

Copy link
Copy Markdown
Contributor

connect(url, { worker }) now accepts a SharedWorker (reached through its port), a dedicated Worker or a raw MessagePort in addition to a ServiceWorker — the page posts to worker.port ?? worker, and every client still gets its own MessageChannel.

WrpcClientProxy listens on both self message (Service Worker/dedicated Worker) and the SharedWorker connect event, treating each page's connection port as the same control bus self is in a Service Worker. It also takes a url option — the server it connects to — instead of always deriving one from self.location, and releases a page's port (and its pending answers) when that port closes.

Also fixes ClientEventTransport.close() being callable only once: a second close(), or terminate() after close(), threw a TypeError that masked the real error from a failed open().

Docs, types, CHANGELOG and the browser bundle budget (15 -> 16 KB; SSE entry 16 -> 17 KB) updated accordingly.

`connect(url, { worker })` now accepts a SharedWorker (reached through its
`port`), a dedicated Worker or a raw MessagePort in addition to a
ServiceWorker — the page posts to `worker.port ?? worker`, and every client
still gets its own MessageChannel.

`WrpcClientProxy` listens on both `self` `message` (Service Worker/dedicated
Worker) and the SharedWorker `connect` event, treating each page's connection
port as the same control bus `self` is in a Service Worker. It also takes a
`url` option — the server it connects to — instead of always deriving one
from `self.location`, and releases a page's port (and its pending answers)
when that port closes.

Also fixes ClientEventTransport.close() being callable only once: a second
close(), or terminate() after close(), threw a TypeError that masked the
real error from a failed open().

Docs, types, CHANGELOG and the browser bundle budget (15 -> 16 KB; SSE entry
16 -> 17 KB) updated accordingly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
wrpc Ready Ready Preview Sep 15, 2026 6:57pm UTC

@Alex-Dolid
Alex-Dolid merged commit 5439aea into feature/v2 Sep 15, 2026
6 checks passed
@Alex-Dolid
Alex-Dolid deleted the feature/shared-worker branch September 15, 2026 18:58

This branch was successfully deployed

1 active deployment
Preview — 2d1b0368 Deployed Sep 15, 2026 by vercel[bot]
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