Skip to content

Commit e6ed4ee

Browse files
committed
workspace: fix README alarm example looping on exhausted retries
retryPendingSync leaves the final intent in storage with a past-due notBefore when a backend exhausts its attempts. The example alarm re-armed on min(notBefore), so an exhausted intent made the alarm fire immediately and repeatedly. Clear exhausted intents in the example.
1 parent 7541ef2 commit e6ed4ee

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

packages/workspace/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,14 @@ export class WorkspaceHost extends DurableObject<Env> {
302302
const now = Date.now();
303303
for (const intent of intents.values()) {
304304
if (intent.notBefore <= now) {
305-
await this.workspace.retryPendingSync(intent.backend);
305+
const result = await this.workspace.retryPendingSync(intent.backend);
306+
// An exhausted backend keeps its final intent in storage with a
307+
// past-due notBefore. Clear it here so it stops driving the alarm;
308+
// otherwise the wake-up fires immediately and forever. Inspect or
309+
// alert before clearing if you need to surface the exhaustion.
310+
if (result.status === "exhausted") {
311+
await this.scheduler.clear(intent.backend);
312+
}
306313
}
307314
}
308315

0 commit comments

Comments
 (0)