You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
setName() persists __ps_name for non-idFromName DOs
For DOs where `ctx.id.name` is undefined (Cloudflare Agents facets and
similar framework-level bootstrap patterns), `setName(name)` now writes
the name to the legacy `__ps_name` storage key in addition to stashing
it in memory. This makes `setName()` the sanctioned bootstrap API:
frameworks no longer need to write `__ps_name` directly themselves —
PartyServer manages its own storage layout.
For DOs addressed via idFromName/getByName, behavior is unchanged:
ctx.id.name carries the name, no storage write happens.
Migration for framework authors who currently do:
await this.ctx.storage.put("__ps_name", name);
await this.__unsafe_ensureInitialized();
becomes:
await this.setName(name);
Backward compatible — the existing direct-storage pattern keeps working
since the storage write becomes idempotent.
Adds SetNameBootstrapServer + 3 tests covering:
1. setName() persists __ps_name for newUniqueId DOs
2. Cold-wake fetch recovers the name via the storage fallback
3. setName() does NOT write storage when ctx.id.name is set (regression
guard for the 0.5.0 zero-storage-write win on the happy path)
Made-with: Cursor
`setName()` is now the sanctioned bootstrap API for non-`idFromName` DOs.
6
+
7
+
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.
8
+
9
+
Frameworks that previously did:
10
+
11
+
```ts
12
+
awaitthis.ctx.storage.put("__ps_name", name);
13
+
awaitthis.__unsafe_ensureInitialized();
14
+
```
15
+
16
+
can now do:
17
+
18
+
```ts
19
+
awaitthis.setName(name);
20
+
```
21
+
22
+
Backward compatible:
23
+
24
+
- 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.
25
+
- The pre-existing direct-storage-write pattern keeps working — the storage write becomes idempotent with what `setName()` would do.
26
+
27
+
`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()`.
0 commit comments