|
1 | 1 | # partyflare |
2 | 2 |
|
| 3 | +## 0.5.2 |
| 4 | + |
| 5 | +### Patch Changes |
| 6 | + |
| 7 | +- [#383](https://github.com/cloudflare/partykit/pull/383) [`fe030f6`](https://github.com/cloudflare/partykit/commit/fe030f62348c7556a57132a4d135a31e71ba21c1) Thanks [@threepointone](https://github.com/threepointone)! - `setName()` is now the sanctioned bootstrap API for non-`idFromName` DOs. |
| 8 | + |
| 9 | + When `ctx.id.name` is undefined (e.g. Cloudflare Agents facets, which are spawned via `ctx.facets.get(...)` rather than `idFromName()`), `setName(name)` now persists the name to the legacy `__ps_name` storage key in addition to stashing it in memory. This means cold-wake invocations of the DO recover the name through `#ensureInitialized()`'s legacy storage fallback without the framework having to reach into PartyServer's private storage layout. |
| 10 | + |
| 11 | + Frameworks that previously did: |
| 12 | + |
| 13 | + ```ts |
| 14 | + await this.ctx.storage.put("__ps_name", name); |
| 15 | + await this.__unsafe_ensureInitialized(); |
| 16 | + ``` |
| 17 | + |
| 18 | + can now do: |
| 19 | + |
| 20 | + ```ts |
| 21 | + await this.setName(name); |
| 22 | + ``` |
| 23 | + |
| 24 | + Backward compatible: |
| 25 | + |
| 26 | + - 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. |
| 27 | + - The pre-existing direct-storage-write pattern keeps working — the storage write becomes idempotent with what `setName()` would do. |
| 28 | + |
| 29 | + `setName()`'s `@deprecated` docblock has been clarified: it remains the supported API for framework-level bootstrap of non-`idFromName` DOs and for delivering initial `props` to `onStart()`. The deprecation only applies to redundant calls on DOs that were addressed via `idFromName()`. |
| 30 | + |
3 | 31 | ## 0.5.1 |
4 | 32 |
|
5 | 33 | ### Patch Changes |
|
9 | 37 | 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()`. |
10 | 38 |
|
11 | 39 | Changes: |
| 40 | + |
12 | 41 | - 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). |
13 | 42 | - `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. |
14 | 43 | - `Server.alarm()` is simplified — it no longer needs its own hydrate call since `#ensureInitialized()` handles it. |
|
23 | 52 | 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. |
24 | 53 |
|
25 | 54 | Changes in `partyserver`: |
| 55 | + |
26 | 56 | - `this.name` resolves from `this.ctx.id.name`. The apologetic `workerd#2240` error message is gone. |
27 | 57 | - `this.name` is now available **inside the constructor** and from class field initializers, not just after `setName()`/`fetch()` has run. |
28 | 58 | - `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. |
|
34 | 64 | - 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. |
35 | 65 |
|
36 | 66 | Changes in all affected packages (`partyserver`, `partysub`, `partysync`, `y-partyserver`, `hono-party`): |
| 67 | + |
37 | 68 | - `@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. |
38 | 69 |
|
39 | 70 | 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. |
|
354 | 385 | ### Patch Changes |
355 | 386 |
|
356 | 387 | - [`528adea`](https://github.com/threepointone/partyserver/commit/528adeaced6dce6e888d2f54cc75c3569bf2c277) Thanks [@threepointone](https://github.com/threepointone)! - some fixes and tweaks |
| 388 | + |
357 | 389 | - getServerByName was throwing on all requests |
358 | 390 | - `Env` is now an optional arg when defining `Server` |
359 | 391 | - `y-partyserver/provider` can now take an optional `prefix` arg to use a custom url to connect |
360 | 392 | - `routePartyKitRequest`/`getServerByName` now accepts `jurisdiction` |
361 | 393 |
|
362 | 394 | bonus: |
| 395 | + |
363 | 396 | - added a bunch of fixtures |
364 | 397 | - added stubs for docs |
365 | 398 |
|
|
0 commit comments