ReleaseCloudflare (Workers AI)Cloudflare (Workers AI)published Jun 12, 2026seen 1w

cloudflare/partykit partysocket@1.2.0

cloudflare/partykit

Open original ↗

Captured source

source ↗
published Jun 12, 2026seen 1wcaptured 1whttp 200method plain

partysocket@1.2.0

Repository: cloudflare/partykit

Tag: partysocket@1.2.0

Published: 2026-06-12T11:26:38Z

Prerelease: no

Release notes:

Minor Changes

  • #403 `7e042eb` Thanks @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().

Notability

notability 2.0/10

Routine minor release, low AI relevance