Repository navigation
fix(sdk): recover once from an expired syncCode cache hit - #673
Open
miyaontherelay wants to merge 1 commit into
Open
miyaontherelay wants to merge 1 commit into
miyaontherelay wants to merge 1 commit into
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
[Medium impact] The PR appears safe to merge; no actionable issues were found.
|
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
Recover once when a content-addressed
syncCodecache hit expires before Cloud copies the archive at run submission. The SDK retains the packed snapshot through the first submission, recognizes only the exact HTTP 503workflow_code_unavailablerefusal, then prepares a new run without a digest, uploads the same snapshot, and submits that new run once. It never retries the terminalized run ID, an ambiguous transport outcome, another refusal, or a cache miss. The spool is removed after success or final failure.Closes #672. Follow-up to #666 for 2.0.52; no package publication or deployment in this PR.
Verification
Against #666's original
cloud-run.ts, with the new tests kept and the source restored byte-for-byte afterward:TMPDIR=/tmp node node_modules/vitest/vitest.mjs run tests/cloud-sync.test.ts -t 'cache hit disappears|makes only one recovery attempt|does not resubmit' --testTimeout=15000At this head:
TMPDIR=/tmp node node_modules/vitest/vitest.mjs run tests/cloud-sync.test.ts tests/cloud-run.test.ts tests/cloud-read.test.ts --minWorkers=1 --maxWorkers=1 --testTimeout=20000npm run typecheck && npm run typecheck:tests && npm run buildgit diff --check— exit 0.Agent Relay sessions
codexsession01a13937· opened viagh pr create· last active 2026-10-16Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Changes hosted run admission and syncCode upload/retry behavior for cache hits; mistakes could double-submit or mishandle terminalized runs, though recovery is narrowly gated and heavily tested.
Overview
Adds a single automatic recovery when
runInCloudusessyncCodeand Cloud returns 503workflow_code_unavailableafter a content-addressed code cache hit (the cached archive vanished before run admission).On a cache hit the SDK now keeps the packed tree (
packedForRecovery) instead of disposing it immediately. Submission is refactored behind asubmit()helper with sharedrewriteRunErrorhandling. If that specific refusal occurs, it prepares a new run without a digest, uploads the same snapshot, updatessyncedto the new run ID, and submits once more—but not if prepare reuses the terminalized run ID, on transport errors, other refusal codes, or after a real upload (cache miss). The spool is disposed in afinallyafter success or failure.onSubmitdocs note it still fires once before the first submission even when a follow-up submission happens after cache expiry. Tests extend the cloud mock to return rawResponseobjects and cover happy-path recovery, one-attempt limits, and cases that must not retry.Reviewed by Cursor Bugbot for commit 1a37e95. Bugbot is set up for automated code reviews on this repo. Configure here.