Repository navigation
Conversation
Rooms can declare named actions that other server code calls with typed arguments. getRoom() reuses the client's instance key and dispatches over Durable Object RPC, so actions run inside the room and are not reachable from client messages or ordinary HTTP.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #689
Description
Let rooms declare named actions that other server code can call through
getRoom()fromvoid/ws/server.An auth hook can pass a session ID to an action that closes matching connections inside the room. The filtering stays in the Durable Object rather than crossing the boundary as a callback. Action arguments and return values retain their declared types.
getRoom()uses the same room addressing as client connections, including route params and custom keys. Actions run over Durable Object RPC, not through an HTTP endpoint or client message. Internal helpers use JavaScript private methods so they are not exposed through RPC.The server-only entry point stays separate from
void/ws. Existing rooms without actions anddefineWebSocketroutes retain their behavior. The guide includes a session-revocation example using server-authenticated session IDs.Current boundaries:
ctx.roomdirectly instead of awaiting an RPC action on their own room.thenis reserved by the actions proxy to prevent accidental Promise assimilation.Test
getRoom()against actual generated route declarations, including invalid calls. The test uses the package's built declarations.The full suite has not passed locally. Earlier runs encountered missing Playwright browsers, an older Node version and missing generated configs; those failures were not compared against the base commit. Live Cloudflare deployment and the development server have not been verified.