From bc51e0789cecd58304fd2beef8c96d46cb2aca57 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 12 Jun 2026 11:24:31 +0000 Subject: [PATCH] Version Packages --- .changeset/spotty-eels-warn.md | 11 ----------- fixtures/alarm-restart-e2e/package.json | 2 +- fixtures/chat/package.json | 2 +- fixtures/globe/package.json | 2 +- fixtures/hono/package.json | 2 +- fixtures/monaco-yjs/package.json | 2 +- fixtures/node/package.json | 2 +- fixtures/pubsub/package.json | 2 +- fixtures/tldraw/package.json | 2 +- fixtures/todo-sync/package.json | 2 +- package-lock.json | 20 ++++++++++---------- packages/partysocket/CHANGELOG.md | 14 ++++++++++++++ packages/partysocket/package.json | 2 +- 13 files changed, 34 insertions(+), 31 deletions(-) delete mode 100644 .changeset/spotty-eels-warn.md diff --git a/.changeset/spotty-eels-warn.md b/.changeset/spotty-eels-warn.md deleted file mode 100644 index c306b92d..00000000 --- a/.changeset/spotty-eels-warn.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -"partysocket": minor ---- - -Make buffered messages and connection teardown reliable across socket replacement and explicit close (see cloudflare/agents#1738). - -- **`close()` now dispatches its `close` event synchronously** (mirroring how `reconnect()` already dispatched its synthetic close). Consumers that detach their listeners right after closing — like the React hooks during cleanup — previously never observed the terminal close event, leaving "connection closed" handling (pending-call rejection, state resets) to never run. After `close()` returns, `readyState` reports `CLOSED` immediately, even while the underlying socket finishes its closing handshake. Code that attached a `close` listener _after_ calling `close()` and relied on the event arriving asynchronously must attach the listener first. -- **`send()` now returns a `boolean`**: `true` if the message was transmitted immediately over an open connection, `false` if it was buffered (delivered when the connection next opens, always before the `open` event is dispatched) or dropped because `maxEnqueuedMessages` was reached. Callers implementing request/response protocols can use this to know whether a request is actually in flight. -- **New `drainQueuedMessages()` method** removes and returns all messages that were buffered by `send()` but never transmitted, so a socket that's being discarded can hand its unsent buffer to a replacement instead of silently losing it. -- **React hooks (`usePartySocket`, `useWebSocket`) now migrate buffered messages when they replace the socket** because connection options changed. By default, buffered messages transfer only when the destination is unchanged (e.g. only `query` — credentials — changed); if destination options (`room`, `party`, `path`, `host`, URL, ...) changed, the messages are discarded with a warning rather than delivered to a destination they weren't composed for. The new `transferEnqueuedMessages` option overrides this: `true` always transfers, `false` never does. -- **Warn when `send()` is called after `close()`.** Messages sent against a permanently closed socket are buffered into a queue that nothing will ever flush (unless `reconnect()` is called later), which silently strands the message — and any caller waiting on a reply. This usually indicates a stale socket reference in the caller. The message is still buffered for backwards compatibility; the warning is emitted once per close cycle and resets on `reconnect()`. diff --git a/fixtures/alarm-restart-e2e/package.json b/fixtures/alarm-restart-e2e/package.json index e3005d3d..21724cbc 100644 --- a/fixtures/alarm-restart-e2e/package.json +++ b/fixtures/alarm-restart-e2e/package.json @@ -10,7 +10,7 @@ "dependencies": { "partyserver": "*", "partyserver-stock": "npm:partyserver@0.5.5", - "partysocket": "^1.1.19" + "partysocket": "^1.2.0" }, "devDependencies": { "@cloudflare/vite-plugin": "^1.34.0", diff --git a/fixtures/chat/package.json b/fixtures/chat/package.json index 17a60ab1..b23efaab 100644 --- a/fixtures/chat/package.json +++ b/fixtures/chat/package.json @@ -10,7 +10,7 @@ "dependencies": { "nanoid": "^5.1.9", "partyserver": "^0.5.6", - "partysocket": "^1.1.19", + "partysocket": "^1.2.0", "react": "^19.2.5", "react-dom": "^19.2.5" }, diff --git a/fixtures/globe/package.json b/fixtures/globe/package.json index bf29d08f..46f28f70 100644 --- a/fixtures/globe/package.json +++ b/fixtures/globe/package.json @@ -10,7 +10,7 @@ "dependencies": { "cobe": "^2.0.1", "partyserver": "^0.5.6", - "partysocket": "^1.1.19", + "partysocket": "^1.2.0", "react": "^19.2.5", "react-dom": "^19.2.5" }, diff --git a/fixtures/hono/package.json b/fixtures/hono/package.json index de2d4c20..0aa1d57b 100644 --- a/fixtures/hono/package.json +++ b/fixtures/hono/package.json @@ -11,7 +11,7 @@ "hono": "^4.12.15", "hono-party": "^2.1.0", "partyserver": "^0.5.6", - "partysocket": "^1.1.19", + "partysocket": "^1.2.0", "react": "^19.2.5", "react-dom": "^19.2.5" }, diff --git a/fixtures/monaco-yjs/package.json b/fixtures/monaco-yjs/package.json index 1825172a..11a89488 100644 --- a/fixtures/monaco-yjs/package.json +++ b/fixtures/monaco-yjs/package.json @@ -10,7 +10,7 @@ }, "dependencies": { "monaco-editor": "^0.55.1", - "partysocket": "^1.1.19", + "partysocket": "^1.2.0", "y-monaco": "^0.1.6" } } diff --git a/fixtures/node/package.json b/fixtures/node/package.json index c04ab18e..91a5efdb 100644 --- a/fixtures/node/package.json +++ b/fixtures/node/package.json @@ -7,6 +7,6 @@ "types": "wrangler types env.d.ts --include-runtime false" }, "dependencies": { - "partysocket": "^1.1.19" + "partysocket": "^1.2.0" } } diff --git a/fixtures/pubsub/package.json b/fixtures/pubsub/package.json index 7cbf73ff..b9d9f6f0 100644 --- a/fixtures/pubsub/package.json +++ b/fixtures/pubsub/package.json @@ -9,6 +9,6 @@ }, "dependencies": { "nanoid": "^5.1.9", - "partysocket": "^1.1.19" + "partysocket": "^1.2.0" } } diff --git a/fixtures/tldraw/package.json b/fixtures/tldraw/package.json index 81bf2fc8..e3f2b240 100644 --- a/fixtures/tldraw/package.json +++ b/fixtures/tldraw/package.json @@ -8,7 +8,7 @@ }, "dependencies": { "partyserver": "^0.5.6", - "partysocket": "^1.1.19", + "partysocket": "^1.2.0", "react": "^19.2.5", "react-dom": "^19.2.5", "tldraw": "^4.5.10" diff --git a/fixtures/todo-sync/package.json b/fixtures/todo-sync/package.json index 96eb6599..14e83297 100644 --- a/fixtures/todo-sync/package.json +++ b/fixtures/todo-sync/package.json @@ -11,7 +11,7 @@ "nanoid": "^5.1.9", "partyfn": "^0.1.0", "partyserver": "^0.5.6", - "partysocket": "^1.1.19", + "partysocket": "^1.2.0", "partysync": "^2.1.0", "react": "^19.2.5", "react-dom": "^19.2.5", diff --git a/package-lock.json b/package-lock.json index 21404848..7c0c60a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,7 +42,7 @@ "dependencies": { "partyserver": "*", "partyserver-stock": "npm:partyserver@0.5.5", - "partysocket": "^1.1.19" + "partysocket": "^1.2.0" }, "devDependencies": { "@cloudflare/vite-plugin": "^1.34.0", @@ -57,7 +57,7 @@ "dependencies": { "nanoid": "^5.1.9", "partyserver": "^0.5.6", - "partysocket": "^1.1.19", + "partysocket": "^1.2.0", "react": "^19.2.5", "react-dom": "^19.2.5" }, @@ -90,7 +90,7 @@ "dependencies": { "cobe": "^2.0.1", "partyserver": "^0.5.6", - "partysocket": "^1.1.19", + "partysocket": "^1.2.0", "react": "^19.2.5", "react-dom": "^19.2.5" }, @@ -107,7 +107,7 @@ "hono": "^4.12.15", "hono-party": "^2.1.0", "partyserver": "^0.5.6", - "partysocket": "^1.1.19", + "partysocket": "^1.2.0", "react": "^19.2.5", "react-dom": "^19.2.5" }, @@ -135,7 +135,7 @@ "version": "0.0.0", "dependencies": { "monaco-editor": "^0.55.1", - "partysocket": "^1.1.19", + "partysocket": "^1.2.0", "y-monaco": "^0.1.6" } }, @@ -143,7 +143,7 @@ "name": "@partyserver/fixture-node", "version": "0.0.0", "dependencies": { - "partysocket": "^1.1.19" + "partysocket": "^1.2.0" } }, "fixtures/partytracks": { @@ -163,7 +163,7 @@ "version": "0.0.0", "dependencies": { "nanoid": "^5.1.9", - "partysocket": "^1.1.19" + "partysocket": "^1.2.0" } }, "fixtures/pubsub/node_modules/nanoid": { @@ -209,7 +209,7 @@ "version": "0.0.11", "dependencies": { "partyserver": "^0.5.6", - "partysocket": "^1.1.19", + "partysocket": "^1.2.0", "react": "^19.2.5", "react-dom": "^19.2.5", "tldraw": "^4.5.10" @@ -226,7 +226,7 @@ "nanoid": "^5.1.9", "partyfn": "^0.1.0", "partyserver": "^0.5.6", - "partysocket": "^1.1.19", + "partysocket": "^1.2.0", "partysync": "^2.1.0", "react": "^19.2.5", "react-dom": "^19.2.5", @@ -11492,7 +11492,7 @@ "license": "ISC" }, "packages/partysocket": { - "version": "1.1.19", + "version": "1.2.0", "license": "MIT", "dependencies": { "event-target-polyfill": "^0.0.4" diff --git a/packages/partysocket/CHANGELOG.md b/packages/partysocket/CHANGELOG.md index 847360eb..85a10a6b 100644 --- a/packages/partysocket/CHANGELOG.md +++ b/packages/partysocket/CHANGELOG.md @@ -1,5 +1,17 @@ # partysocket +## 1.2.0 + +### Minor Changes + +- [#403](https://github.com/cloudflare/partykit/pull/403) [`7e042eb`](https://github.com/cloudflare/partykit/commit/7e042ebeb2e2796a76079a102f8d95ad07e39946) Thanks [@threepointone](https://github.com/threepointone)! - Make buffered messages and connection teardown reliable across socket replacement and explicit close (see cloudflare/agents#1738). + + - **`close()` now dispatches its `close` event synchronously** (mirroring how `reconnect()` already dispatched its synthetic close). Consumers that detach their listeners right after closing — like the React hooks during cleanup — previously never observed the terminal close event, leaving "connection closed" handling (pending-call rejection, state resets) to never run. After `close()` returns, `readyState` reports `CLOSED` immediately, even while the underlying socket finishes its closing handshake. Code that attached a `close` listener _after_ calling `close()` and relied on the event arriving asynchronously must attach the listener first. + - **`send()` now returns a `boolean`**: `true` if the message was transmitted immediately over an open connection, `false` if it was buffered (delivered when the connection next opens, always before the `open` event is dispatched) or dropped because `maxEnqueuedMessages` was reached. Callers implementing request/response protocols can use this to know whether a request is actually in flight. + - **New `drainQueuedMessages()` method** removes and returns all messages that were buffered by `send()` but never transmitted, so a socket that's being discarded can hand its unsent buffer to a replacement instead of silently losing it. + - **React hooks (`usePartySocket`, `useWebSocket`) now migrate buffered messages when they replace the socket** because connection options changed. By default, buffered messages transfer only when the destination is unchanged (e.g. only `query` — credentials — changed); if destination options (`room`, `party`, `path`, `host`, URL, ...) changed, the messages are discarded with a warning rather than delivered to a destination they weren't composed for. The new `transferEnqueuedMessages` option overrides this: `true` always transfers, `false` never does. + - **Warn when `send()` is called after `close()`.** Messages sent against a permanently closed socket are buffered into a queue that nothing will ever flush (unless `reconnect()` is called later), which silently strands the message — and any caller waiting on a reply. This usually indicates a stale socket reference in the caller. The message is still buffered for backwards compatibility; the warning is emitted once per close cycle and resets on `reconnect()`. + ## 1.1.19 ### Patch Changes @@ -337,6 +349,7 @@ ### Patch Changes - [#251](https://github.com/partykit/partykit/pull/251) [`049bcac`](https://github.com/partykit/partykit/commit/049bcac42aa49e4bddec975c63b7d7984112e450) Thanks [@threepointone](https://github.com/threepointone)! - small tweaks to `init` + - replace `process.env.PARTYKIT_HOST` with just `PARTYKIT_HOST` - add a `tsconfig.json` - add partykit to devDependencies in `init` @@ -357,6 +370,7 @@ - [#211](https://github.com/partykit/partykit/pull/211) [`fffe721`](https://github.com/partykit/partykit/commit/fffe72148e5cc425e80c90b6bf180192df410080) Thanks [@threepointone](https://github.com/threepointone)! - update dependencies - [#191](https://github.com/partykit/partykit/pull/191) [`39cf5ce`](https://github.com/partykit/partykit/commit/39cf5cebf5e699bc50ace8b6d25cd82c807e863a) Thanks [@jevakallio](https://github.com/jevakallio)! - Improve PartySocket types and React hooks API: + - Add websocket lifecycle event handlers to usePartyKit options to reduce need for effects in userland - Allow usePartySocket to provide startClosed option to initialize without opening connection - Fix types for PartySocket#removeEventListener diff --git a/packages/partysocket/package.json b/packages/partysocket/package.json index 459e4604..a2928052 100644 --- a/packages/partysocket/package.json +++ b/packages/partysocket/package.json @@ -1,6 +1,6 @@ { "name": "partysocket", - "version": "1.1.19", + "version": "1.2.0", "description": "A better WebSocket that Just Works™", "homepage": "https://docs.partykit.io/reference/partysocket-api", "bugs": "https://github.com/cloudflare/partykit/issues",