Skip to content

fix: use ctx.waitUntil for deferred da-admin reload to survive hibernation#170

Open
kptdobe wants to merge 1 commit into
mainfrom
fix/do-settimeout-hibernation
Open

fix: use ctx.waitUntil for deferred da-admin reload to survive hibernation#170
kptdobe wants to merge 1 commit into
mainfrom
fix/do-settimeout-hibernation

Conversation

@kptdobe
Copy link
Copy Markdown
Contributor

@kptdobe kptdobe commented Jun 2, 2026

When a document cannot be restored from worker storage, `persistence.bindState` schedules a 1-second delayed reload from da-admin via `setTimeout`. If the Durable Object hibernates within that window, the timer is dropped and the reload never happens for that session.

The fix threads `ctx` (DurableObjectState) from `DocRoom` through `setupWSConnection` → `getYDoc` → `bindState` and replaces the bare `setTimeout` with `ctx.waitUntil(promise)`, keeping the DO alive until the deferred reload completes. Callers without `ctx` (tests, non-hibernating mode) fall back gracefully via `ctx?.waitUntil`.

🤖 Generated with Claude Code

…ernation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: kptdobe <acapt@adobe.com>
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.

2 participants