Skip to content

Commit 86a1b29

Browse files
github-actions[bot]threepointone
authored andcommitted
Version Packages
1 parent 8a3bc02 commit 86a1b29

10 files changed

Lines changed: 38 additions & 31 deletions

File tree

.changeset/facet-name-resolution.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

fixtures/chat/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"dependencies": {
1111
"nanoid": "^5.1.9",
12-
"partyserver": "^0.5.2",
12+
"partyserver": "^0.5.3",
1313
"partysocket": "^1.1.18",
1414
"react": "^19.2.5",
1515
"react-dom": "^19.2.5"

fixtures/globe/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"dependencies": {
1111
"cobe": "^2.0.1",
12-
"partyserver": "^0.5.2",
12+
"partyserver": "^0.5.3",
1313
"partysocket": "^1.1.18",
1414
"react": "^19.2.5",
1515
"react-dom": "^19.2.5"

fixtures/hono/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"dependencies": {
1111
"hono": "^4.12.15",
1212
"hono-party": "^2.1.0",
13-
"partyserver": "^0.5.2",
13+
"partyserver": "^0.5.3",
1414
"partysocket": "^1.1.18",
1515
"react": "^19.2.5",
1616
"react-dom": "^19.2.5"

fixtures/tiptap-yjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"@tiptap/extension-collaboration": "^3.22.4",
1212
"@tiptap/react": "^3.22.4",
1313
"@tiptap/starter-kit": "^3.22.4",
14-
"partyserver": "^0.5.2",
14+
"partyserver": "^0.5.3",
1515
"react": "^19.2.5",
1616
"react-dom": "^19.2.5",
1717
"tailwindcss": "^4.2.4",

fixtures/tldraw/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"start": "vite dev"
88
},
99
"dependencies": {
10-
"partyserver": "^0.5.2",
10+
"partyserver": "^0.5.3",
1111
"partysocket": "^1.1.18",
1212
"react": "^19.2.5",
1313
"react-dom": "^19.2.5",

fixtures/todo-sync/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"dependencies": {
1111
"nanoid": "^5.1.9",
1212
"partyfn": "^0.1.0",
13-
"partyserver": "^0.5.2",
13+
"partyserver": "^0.5.3",
1414
"partysocket": "^1.1.18",
1515
"partysync": "^2.1.0",
1616
"react": "^19.2.5",

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/partyserver/CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# partyflare
22

3+
## 0.5.3
4+
5+
### Patch Changes
6+
7+
- [#386](https://github.com/cloudflare/partykit/pull/386) [`8a3bc02`](https://github.com/cloudflare/partykit/commit/8a3bc02d805ab802dc80d4a2e14f2ee0d6ccda1a) Thanks [@threepointone](https://github.com/threepointone)! - Document and test the supported pattern for using PartyServer with [Durable Object Facets](https://developers.cloudflare.com/dynamic-workers/usage/durable-object-facets/). No runtime behavior change.
8+
9+
**Background.** Facets spawned via `ctx.facets.get(name, factory)` _without_ an explicit `id` in `FacetStartupOptions` inherit the parent DO's `ctx.id` — including `ctx.id.name`. PartyServer's `name` getter reads `ctx.id.name` straight through, so on an implicit-id facet `this.name` returns the _parent's_ name rather than the facet's logical name. This is a faithful reflection of the workerd contract, but it's almost never what framework authors expect.
10+
11+
The fix is at the call site, not in PartyServer: pass `id: someBoundDONamespace.idFromName(facetName)` to `ctx.facets.get(...)`. The facet then gets its own native `ctx.id.name === facetName` and PartyServer's `name` getter does the right thing automatically. No `setName()` is required, no `__ps_name` storage record is written, and cold-wake recovery happens for free because the factory re-runs and `idFromName` is deterministic.
12+
13+
This release adds:
14+
15+
- **A "Using PartyServer with Durable Object Facets" section in the README** that walks through the recommended pattern with a code example, calls out the implicit-id footgun explicitly, and documents that plain-string `id` values are not a substitute for `idFromName(facetName)` (workerd treats string ids as `idFromString`-like, so the resulting facet has no `ctx.id.name`).
16+
- **`setName()` docstring updated** to clarify that facets are NOT a `setName()` use case — point to the explicit-`id` pattern instead. The original `setName()` `ctx.id.name` mismatch throw is preserved as a typo guard for the `idFromName` happy path.
17+
- **End-to-end facet test coverage** against the real workerd `ctx.facets.get(...)` API. A `FacetParent` / `FacetChild` fixture exercises both the implicit-id path (pinning the runtime contract that `this.name` returns the parent's name in that flow — i.e., behavior-as-documentation so framework authors are unsurprised) and the explicit-id path (recommended; verifies that all reasonable id-construction strategies work and that cold wake recovers without any storage record). Plain-string `id` is also tested; the test asserts it does NOT carry a name, pinning the contract so callers don't get tempted by the type signature.
18+
19+
The runtime behavior of `Server` (the `name` getter, `setName()`, the legacy `__ps_name` hydrate inside `#ensureInitialized()`) is unchanged from 0.5.2.
20+
321
## 0.5.2
422

523
### Patch Changes
@@ -22,6 +40,7 @@
2240
```
2341

2442
Backward compatible:
43+
2544
- For DOs addressed via `idFromName()` / `getByName()` (the happy path), `setName()` continues to NOT write storage — `ctx.id.name` is the source of truth and `setName()` is just a no-op-plus-onStart.
2645
- The pre-existing direct-storage-write pattern keeps working — the storage write becomes idempotent with what `setName()` would do.
2746

@@ -36,6 +55,7 @@
3655
0.5.0 moved the legacy storage hydrate into `alarm()` only, breaking Cloudflare Agents facets and any other framework that writes `__ps_name` directly before calling `__unsafe_ensureInitialized()`. Facet DOs are spawned via `ctx.facets.get(...)` rather than `idFromName()` and therefore have `ctx.id.name === undefined`; they relied on PartyServer reading the storage record back to populate `this.name` before `onStart()`.
3756

3857
Changes:
58+
3959
- Move the legacy `__ps_name` hydrate from `alarm()` into `#ensureInitialized()`, still gated on `!ctx.id.name && !#_name` so it costs nothing on the happy path (normal `idFromName()`/`getByName()` DOs skip the storage read entirely).
4060
- `Server.fetch()` now delegates to `#ensureInitialized()` for the hydrate instead of doing its own. The `x-partykit-room` header fallback remains as a last resort when neither `ctx.id.name` nor a legacy storage record is available.
4161
- `Server.alarm()` is simplified — it no longer needs its own hydrate call since `#ensureInitialized()` handles it.
@@ -50,6 +70,7 @@
5070
Durable Objects now expose `ctx.id.name` on every entry point (constructor, fetch, alarm, hibernating websocket handlers) when the DO is addressed via `idFromName()`/`getByName()`. PartyServer now uses this as the primary source of `this.name`, which simplifies routing, eliminates storage writes, and makes `this.name` available inside the constructor.
5171

5272
Changes in `partyserver`:
73+
5374
- `this.name` resolves from `this.ctx.id.name`. The apologetic `workerd#2240` error message is gone.
5475
- `this.name` is now available **inside the constructor** and from class field initializers, not just after `setName()`/`fetch()` has run.
5576
- `routePartykitRequest` no longer issues a `setName()`/`_initAndFetch()` RPC before `fetch()`. The WebSocket path goes from 2 RPCs to 1; the HTTP path remains 1 RPC. Props, when supplied, are delivered to the DO via the `x-partykit-props` request header, set after `onBeforeConnect`/`onBeforeRequest` hooks run.
@@ -61,6 +82,7 @@
6182
- When reading `this.name` throws, it is because `ctx.id.name` is undefined and no legacy fallback has populated the name: the DO was addressed via `idFromString()` or `newUniqueId()` (both unsupported), the runtime is too old to expose `ctx.id.name`, or a pre-2026-03-15 alarm fired before the legacy storage fallback ran.
6283

6384
Changes in all affected packages (`partyserver`, `partysub`, `partysync`, `y-partyserver`, `hono-party`):
85+
6486
- `@cloudflare/workers-types` peer dependency bumped from `^4.20240729.0` to `^4.20260424.1`. The old range predates `ctx.id.name` in the type surface.
6587

6688
Not supported: addressing PartyServer DOs via `idFromString()` or `newUniqueId()`. These paths return `ctx.id.name === undefined` inside the DO and will surface as a clear error from `this.name`. PartyServer has always assumed name-based addressing via `getServerByName` / `routePartykitRequest`; this release makes that assumption explicit.
@@ -381,12 +403,14 @@
381403
### Patch Changes
382404

383405
- [`528adea`](https://github.com/threepointone/partyserver/commit/528adeaced6dce6e888d2f54cc75c3569bf2c277) Thanks [@threepointone](https://github.com/threepointone)! - some fixes and tweaks
406+
384407
- getServerByName was throwing on all requests
385408
- `Env` is now an optional arg when defining `Server`
386409
- `y-partyserver/provider` can now take an optional `prefix` arg to use a custom url to connect
387410
- `routePartyKitRequest`/`getServerByName` now accepts `jurisdiction`
388411

389412
bonus:
413+
390414
- added a bunch of fixtures
391415
- added stubs for docs
392416

packages/partyserver/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "partyserver",
3-
"version": "0.5.2",
3+
"version": "0.5.3",
44
"repository": {
55
"type": "git",
66
"url": "git://github.com/cloudflare/partykit.git"

0 commit comments

Comments
 (0)