Skip to content

Commit f410527

Browse files
committed
Correct changeset: add peer-dep bump, list affected packages, clarify
- Bump partysub, partysync, y-partyserver, hono-party to minor too since they all had their @cloudflare/workers-types peer range narrowed. - Note the peer dep change explicitly. - Note the improved error message. - Clarify the "when does .name throw" claim (it covers runtime-too-old and the narrow pre-2026-03-15 alarm window, not just unsupported id addressing). Made-with: Cursor
1 parent b99c1da commit f410527

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

.changeset/ctx-id-name.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
---
22
"partyserver": minor
3+
"partysub": minor
4+
"partysync": minor
5+
"y-partyserver": minor
6+
"hono-party": minor
37
---
48

59
Use native `ctx.id.name` to populate `this.name`.
610

711
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.
812

9-
Changes:
13+
Changes in `partyserver`:
1014

11-
- `this.name` resolves from `this.ctx.id.name`. The apologetic `workerd#2240` error message is gone; the getter only throws when the DO is addressed via `idFromString()`/`newUniqueId()` (unsupported).
12-
- `this.name` is now available inside the constructor and inside `onStart()` on cold wake without any prior `setName()` round trip.
13-
- `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.
14-
- `getServerByName` continues to perform a single RPC to ensure `onStart()` has completed before returning, so user-defined RPC methods can rely on initialization being done. That RPC is now cheaper internally (no storage write; name is read from `ctx.id.name`).
15-
- `Server` no longer writes the `__ps_name` record to storage. Existing records remain on disk for backward compatibility and are only read inside `alarm()` as a fallback for alarms that were scheduled before 2026-03-15 (where `ctx.id.name` is not carried into the alarm handler; see the [Durable Objects ID docs](https://developers.cloudflare.com/durable-objects/api/id/#name)).
15+
- `this.name` resolves from `this.ctx.id.name`. The apologetic `workerd#2240` error message is gone.
16+
- `this.name` is now available **inside the constructor** and from class field initializers, not just after `setName()`/`fetch()` has run.
17+
- `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.
18+
- `getServerByName` continues to perform a single RPC to ensure `onStart()` has completed before returning, so user-defined RPC methods on the returned stub can rely on initialization being done. That RPC is now cheaper internally (no storage write; name is read from `ctx.id.name`).
19+
- `Server` no longer writes the `__ps_name` record to storage. Existing records remain on disk for backward compatibility and are only read inside `alarm()` as a fallback for alarms that were scheduled before 2026-03-15 (where `ctx.id.name` is not carried into the alarm handler see the [Durable Objects ID docs](https://developers.cloudflare.com/durable-objects/api/id/#name)).
1620
- `setName()` and `_initAndFetch()` are marked `@deprecated`. They continue to work for backward compatibility. `setName(name)` now throws if `name` does not match `ctx.id.name`.
1721
- The `x-partykit-room` header is still accepted as a fallback when `ctx.id.name` is not available.
22+
- Error message when the name cannot be resolved has been rewritten to list the three real causes (unsupported addressing via `idFromString()`/`newUniqueId()`, runtime too old to expose `ctx.id.name`, or direct `stub.fetch()` without `routePartykitRequest`/`getServerByName`).
23+
- 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.
1824

19-
Not supported: addressing PartyServer DOs via `idFromString()` or `newUniqueId()`. These paths return `ctx.id.name === undefined` inside the DO, which 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.
25+
Changes in all affected packages (`partyserver`, `partysub`, `partysync`, `y-partyserver`, `hono-party`):
26+
27+
- `@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.
28+
29+
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.

0 commit comments

Comments
 (0)