Skip to content

fix(workspaces): retry transient Durable Object storage resets#626

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/kernel-transient-do-reset
Draft

fix(workspaces): retry transient Durable Object storage resets#626
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/kernel-transient-do-reset

Conversation

@posthog

@posthog posthog Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

A transient Cloudflare Durable Object reset surfaced as an uncaught SqlError in WorkspaceKernel storage. When Cloudflare evicts or resets a DO mid-query, ctx.storage.sql.exec throws "…caused object to be reset", which the agents runtime rewraps as SqlError: SQL query failed: …. The kernel had no transient/retryable classification, so these platform blips bubbled up through runMutationrecordOperationalOutcome and registered in error tracking as handled-but-unhandled failures — infrastructure noise, not a broken flow.

Notably, @cloudflare/sandbox's isPlatformTransientError (already used for sandbox failures) does not match this error: it only recognizes the startup storage-reset variant, not the mid-query reset. So this adds a small dedicated classifier.

  • New workspace-kernel-storage.ts: isTransientStorageError (matches DO reset / superseded-isolate / lost-connection signatures, walking the error's cause chain) and runKernelSqlWithRetry (bounded 3-attempt immediate retry).
  • kernelSql now runs through the retry wrapper, so every kernel SQL op benefits.
  • runMutation logs a reset that outlives the retry as a rejected outcome instead of capturing it as an unhandled exception.

Why

These resets are momentary platform events where nobody loses data, but without transient classification they looked like real bugs in error tracking. A small robustness pass keeps them from registering as unhandled failures.

Test plan

  • New unit tests in workspace-kernel-storage.test.ts cover classification (mid-query reset via wrapped SqlError, raw reset, genuine query defect, non-error values) and retry behavior (retry-then-succeed, no-retry on real defects, bounded give-up).
  • pnpm check (format + typecheck + lint) passes.

Created with PostHog Code from an inbox report.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Review in cubic

Cloudflare can evict or reset a Durable Object mid-query, causing
`ctx.storage.sql.exec` to throw "…caused object to be reset", which the
`agents` runtime rewraps as a SqlError. The WorkspaceKernel had no
transient classification, so these platform blips bubbled up and were
captured to error tracking as unhandled failures.

Classify these resets as transient, retry the SQL op a bounded number
of times (storage ops are cheap and the reset is momentary), and log a
surviving reset as a rejected outcome instead of an unhandled exception.

Generated-By: PostHog Code
Task-Id: 5357de1a-dc12-4c8f-ba43-329df7ac0183
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

0 participants