Title: WebSockets: a server-side handle to a room, to broadcast to or close its connections from other server code · Issue #689 · voidzero-dev/void · GitHub
Open Graph Title: WebSockets: a server-side handle to a room, to broadcast to or close its connections from other server code · Issue #689 · voidzero-dev/void
X Title: WebSockets: a server-side handle to a room, to broadcast to or close its connections from other server code · Issue #689 · voidzero-dev/void
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.dele...
Open Graph 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 sessio...
X 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 se...
Opengraph URL: https://github.com/voidzero-dev/void/issues/689
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"WebSockets: a server-side handle to a room, to broadcast to or close its connections from other server code","articleBody":"Void 1.5.0, Cloudflare target, `defineRoom` in a `*.ws.ts` route.\n\nWe 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.\n\nThe only way we found is undocumented: the binding name Void generates (from `void.lock.json`), `idFromName('\u003cparam>=\u003cvalue>')`, and a request handled in `onRequest`. We do not want to depend on those internals.\n\nProposal: a server-side handle to a room instance, for example:\n\n```ts\nimport { getRoom } from 'void/ws';\n\nconst room = getRoom('/relay/:accountId', { params: { accountId } });\nawait room.broadcast(event);\nawait room.close({ code: 4001, reason: 'session revoked', filter: (connection) => connection.state.sessionId === id });\n```\n\nusable from route handlers, auth hooks, queues and cron jobs, and addressing the same instance a client's `connect()` would.\n","author":{"url":"https://github.com/IKatsuba","@type":"Person","name":"IKatsuba"},"datePublished":"2026-11-03T15:34:04Z","url":"https://github.com/voidzero-dev/void/issues/689"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ded69d7c-9423-85fc-afc6-28847a19986a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D7B6:23725B:1B29CAF:24F321C:6AFB8B36 |
| html-safe-nonce | e7881f898afd4268a7bdc99c95125912b06720bab1d875f25a5017f0ed72eacb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEN0I2OjIzNzI1QjoxQjI5Q0FGOjI0RjMyMUM6NkFGQjhCMzYiLCJ2aXNpdG9yX2lkIjoiNDQwMDIyMTAwMzMwMTIyNzMxOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e8399bf11e498e243e625862651a59dcbd345c9346e1d77d535db997b30d9274 |
| hovercard-subject-tag | issue:6185823215 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/voidzero-dev/void/689/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4aca0ed3766c1344b9d23ef0ac97ad34d240dc337f285575bf1ea25d5a5fe77f/voidzero-dev/void/issues/689 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4aca0ed3766c1344b9d23ef0ac97ad34d240dc337f285575bf1ea25d5a5fe77f/voidzero-dev/void/issues/689 |
| og:image:alt | 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 sessio... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | IKatsuba |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9694464143465782ecae2a97650b2a2b0708d5c31c74f41ee86da57e315e2735 |
| turbo-cache-control | no-preview |
| go-import | github.com/voidzero-dev/void git https://github.com/voidzero-dev/void.git |
| octolytics-dimension-user_id | 149750581 |
| octolytics-dimension-user_login | voidzero-dev |
| octolytics-dimension-repository_id | 1164437080 |
| octolytics-dimension-repository_nwo | voidzero-dev/void |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1164437080 |
| octolytics-dimension-repository_network_root_nwo | voidzero-dev/void |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 05d967182208691fc7f2e6af52e82fa7fabf6bd5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width