WebSockets: a server-side handle to a room, to broadcast to or close its connections from other server code
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- backend, distributed-systems
Research direction
Start by reading the defineRoom API for *.ws.ts routes and the existing onRequest approach described in the issue; inspect how the generated binding in void.lock.json identifies a room instance. The proposal calls for a supported server-side handle usable from route handlers, auth hooks, queues, and cron jobs. Done means external code can address the same room instance as a client's connect() and use it to broadcast or close selected connections.
Written by the indexing model from the issue text.
Description
Void 1.5.0, Cloudflare target, defineRoom in a *.ws.ts route.
We need to reach a room from server code outside its own hooks. Our case is closing a user's open sockets when their Better Auth session is revoked: databaseHooks.session.delete.after fires on every revoke, sign-out and user deletion, but from there nothing in Void's API reaches the room's Durable Object. The docs only suggest re-checking records in onMessage and closing, which leaves an idle socket of a revoked session open until its next frame, and costs a database read per frame.
The only way we found is undocumented: the binding name Void generates (from void.lock.json), idFromName('<param>=<value>'), and a request handled in onRequest. We do not want to depend on those internals.
Proposal: a server-side handle to a room instance, for example:
import { getRoom } from 'void/ws';
const room = getRoom('/relay/:accountId', { params: { accountId } });
await room.broadcast(event);
await room.close({ code: 4001, reason: 'session revoked', filter: (connection) => connection.state.sessionId === id });
usable from route handlers, auth hooks, queues and cron jobs, and addressing the same instance a client's connect() would.
- Dominant language
- TypeScript
- Stars
- 627
- Forks
- 66
- Avg merge
- 14h 38m
- Merged PRs (30d)
- 179
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from voidzero-dev/void
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
voidzero-dev/void#677 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
voidzero-dev/void#686 ·
Maintainers usually reply within 1 day
-
`VoidActionError.message` ignores the server's message, though the docs show it to usersPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 52/100
voidzero-dev/void#680 ·
Maintainers usually reply within 1 day
-
`withValidator({ body })` rejects the multipart bodies that `useForm` and `action()` send for filesOpen
Difficulty 4/5 3-5 days Newbie friendliness 35/100
voidzero-dev/void#679 ·
Maintainers usually reply within 1 day
-
`Link`: mark the link to the current page (`aria-current`, `data-active`)Possibly taken @yangshun claimed this today. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
voidzero-dev/void#676 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
All issues in voidzero-dev/void
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
bug needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
DSpace/dspace-angular#6511 ·
Maintainers usually reply within 1 day
-
area: frontend area:byok bug severity:low
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Phone app shows Unknown for a remote machine whose key changedPossibly taken @janicduplessis claimed this today. Openarea: mobile priority: P3 type: bug
Difficulty 1/5 Under an hour Newbie friendliness 78/100
appandflow/stim#5006 · 1 comment ·
Maintainers usually reply within 1 day
-
Area - Local to Cloud Bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
microsoft/vscode-mssql#23209 ·
Maintainers usually reply within 1 day