Skip to content

Persist room name to DO storage#334

Closed
anchpop wants to merge 1 commit intocloudflare:mainfrom
anchpop:persist-room-name-for-alarm-cold-starts
Closed

Persist room name to DO storage#334
anchpop wants to merge 1 commit intocloudflare:mainfrom
anchpop:persist-room-name-for-alarm-cold-starts

Conversation

@anchpop
Copy link

@anchpop anchpop commented Feb 19, 2026

Closes #32.

What:

This PR allows alarm cold starts to access the room name.

Why:

This removes a footgun (I hit this today)

How:

setName() writes the name to storage under __partyserver_name. #initialize() restores it before onStart() if the name isn't set. (IIUC, only alarms will hit this code path.) fetch() also validates that an incoming x-partykit-room header matches the stored name.

Note:

I considered allowing fetch to restore the room name from storage if x-partykit-room was unset. But that would be a bigger deviation from the current behavior than necessary to close #32. If there any code for like moving DOs between rooms, this PR will obviously break that, but I couldn't find any such code.

I couldn't find a way to make a durable object cold start in the tests, so I couldn't directly add a test for the intended functionality. However, I did add a test that the __partyserver_name field gets set, and that alarms work when that field gets set. The tests fail without this fix and pass with it.

Disclaimer: I used LLM assistance to create this PR. I've reviewed the code of course. This PR description is written by me. (I might seem LLM-ey but I just talk like this)

@changeset-bot
Copy link

changeset-bot bot commented Feb 19, 2026

🦋 Changeset detected

Latest commit: 3ef12c7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
partyserver Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@anchpop anchpop force-pushed the persist-room-name-for-alarm-cold-starts branch from 3bed22e to bd1d3fd Compare February 19, 2026 06:26
@anchpop anchpop force-pushed the persist-room-name-for-alarm-cold-starts branch from bd1d3fd to 3ef12c7 Compare February 19, 2026 06:29
@threepointone
Copy link
Collaborator

fixed in #337 cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

this.name should be available inside alarms

2 participants