fix(workspaces): retry transient Durable Object storage resets#626
Draft
posthog[bot] wants to merge 1 commit into
Draft
fix(workspaces): retry transient Durable Object storage resets#626posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A transient Cloudflare Durable Object reset surfaced as an uncaught
SqlErrorinWorkspaceKernelstorage. When Cloudflare evicts or resets a DO mid-query,ctx.storage.sql.execthrows"…caused object to be reset", which theagentsruntime rewraps asSqlError: SQL query failed: …. The kernel had no transient/retryable classification, so these platform blips bubbled up throughrunMutation→recordOperationalOutcomeand registered in error tracking as handled-but-unhandled failures — infrastructure noise, not a broken flow.Notably,
@cloudflare/sandbox'sisPlatformTransientError(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.workspace-kernel-storage.ts:isTransientStorageError(matches DO reset / superseded-isolate / lost-connection signatures, walking the error's cause chain) andrunKernelSqlWithRetry(bounded 3-attempt immediate retry).kernelSqlnow runs through the retry wrapper, so every kernel SQL op benefits.runMutationlogs a reset that outlives the retry as arejectedoutcome 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
workspace-kernel-storage.test.tscover classification (mid-query reset via wrappedSqlError, 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.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.