-
Notifications
You must be signed in to change notification settings - Fork 59
Check for hibernated websocket connections #312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check for hibernated websocket connections #312
Conversation
🦋 Changeset detectedLatest commit: 7eccf4f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
brother what on earth is this PR |
|
@threepointone pls read the description, it fixes a bug from using the Agents SDK with hibernated websockets |
threepointone
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, dropped a couple of comments on code that probably shouldn't be there. Let's run CI on this
package.json
Outdated
| "@cloudflare/vite-plugin": "^1.19.0", | ||
| "@cloudflare/vitest-pool-workers": "^0.10.4", | ||
| "@ianvs/prettier-plugin-sort-imports": "^4.7.0", | ||
| "@rolldown/binding-darwin-arm64": "^1.0.0-beta.55", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needed to get native rolldown bindings to build locally on Mac (npm run build). Can remove if youd like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like it broke CI, Ill remove it
packages/partyserver/package.json
Outdated
| { | ||
| "name": "partyserver", | ||
| "version": "0.1.0", | ||
| "version": "0.1.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
|
could you revert the changes to package-lock.json as well please? |
|
@threepointone done |
|
/oc review |
Co-authored-by: threepointone <threepointone@users.noreply.github.com>
PR Review SummaryThis PR fixes a real issue when using PartyServer alongside the Agents SDK with hibernated WebSockets. The problem occurs when user code calls What the PR does:
Code quality:
Minor suggestions:
VerdictApprove with minor suggestion: The PR correctly solves a real interoperability issue with proper defensive coding and good test coverage. The implementation is sound. The only actionable item is adding a changeset if a version bump is desired. |
Refactors test files to ensure event handlers are attached before connections, adds explicit type annotations for WebSocket instances, and improves cleanup logic for server and client resources. These changes enhance test reliability, prevent race conditions, and improve type safety in both browser and Node.js environments.
|
using this PR to sneak in some test fixes |
Improves reliability of usePartySocket tests by setting up server connection handlers before rendering hooks and removing unnecessary waits for connection establishment. Also ensures proper cleanup of event listeners after each test.

When using the Agents SDK along with hibernated websockets, partyserver indiscriminately tries to broadcast messages to all connections (from
ctx.getWebSockets()), including foreign hibernated sockets accepted via ctx.acceptWebSocket(). Those sockets dont have partyserver's__pkattachment metadata, so readingconnection.idthrows the following error:This PR adds logic to detect whether a WebSocket has PartyServer’s __pk attachment and skips non-PartyServer sockets . Also ignores non-PartyServer sockets in webSocketMessage/webSocketClose/webSocketError so we never attempt to rehydrate them into a Connection.
tryGetPartyServerMetacan probably be refined, not too familiar with this repo