fix(workspaces): stop checkpointing inside the AI edit turn - #785
Draft
posthog[bot] wants to merge 1 commit into
Draft
fix(workspaces): stop checkpointing inside the AI edit turn#785posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
DocumentSession.applyEdits committed the Yjs update and edit receipt to Durable Object storage, then awaited the Postgres checkpoint in the same turn. That checkpoint takes a contended workspace row lock, so the storage writes stayed open across a slow round trip and Cloudflare reset the object, failing the user's AI edit. - Drop the inline checkpoint from applyEdits and undoDocumentEditReceipt. The document mutation already schedules the debounced onSave, which checkpoints to Postgres off the edit turn. - Classify the "caused object to be reset" error as transient and retry the edit RPC with a fresh session stub. The operation id keeps the replay idempotent. Generated-By: PostHog Desktop Task-Id: cb7529ed-3ab7-451d-ab42-ce81a3ced4ce
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
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.
Problem
workspace_edit_itemflow.DocumentSession.applyEditscommitted the Yjs update and edit receipt to Durable Object storage, then awaited the Postgres checkpoint in the same turn.commitWorkspaceDocumentCheckpointtakes aselect ... for updateon the workspace row. Under lock contention the storage writes stayed open across that round trip, so Cloudflare reset the object (storage operation exceeded timeout which caused object to be reset).Changes
applyEdits(andundoDocumentEditReceipt) now commit their storage transaction and return. The document mutation already schedules the debouncedonSave, which is the single path that checkpoints to Postgres — now off the user-facing turn.caused object to be resetmessage (the sandbox runtime'sisPlatformTransientErroronly matches the startup variant) and retries the edit RPC with a fresh session stub. The operation id keeps the replay idempotent, so a blip no longer fails the edit.Notes
onLoadre-drives it.undoDocumentEditReceiptno longer reportsnot_foundwhen the item was deleted concurrently; the deferred checkpoint still purges a discarded item.Test plan
document-session-transient.test.ts).pnpm check(format + typecheck + lint) passes; workspace document and operation suites pass.Created with PostHog Desktop from this inbox report.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.