Skip to content

fix(sandbox): auto-retry transient SANDBOX_START failures without a refresh - #5195

Merged
pedrofrxncx merged 2 commits into
mainfrom
fix/sandbox-start-retry-transient
Jul 24, 2026
Merged

pedrofrxncx merged 2 commits into
mainfrom
fix/sandbox-start-retry-transient

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Transient SANDBOX_START failures surfaced a 500 to the frontend that the user had to clear by refreshing the page. This retries them in-place so the booting overlay holds and the sandbox comes up on its own.

Found via VictoriaLogs (prod, eks-serverless, last 24h): of 20 SANDBOX_START 5xx, 6 were concurrency-transient — a racing start/stop/reap holding the per-branch lock:

  • agent sandbox lifecycle transition in progress … retry shortly (agent-sandbox-sessions.ts:207)
  • … lifecycle lock busy … retry shortly (agent-sandbox-sessions.ts:95)
  • sandbox advisory lock busy … retry shortly (*-runner-state.ts)

The server already tags exactly these with a retry shortly marker. This keys off that contract and lets react-query retry the mutation (retry/retryDelay, matching the existing use-publish-gate.ts pattern). The mutation stays isPending across retries, so the UI keeps showing "Booting…" instead of flipping to the error state — no refresh.

Scope

Retries only the retry shortly class. Deliberately excluded:

  • Sandbox start was superseded by a stop — retrying could resurrect a sandbox the user just stopped.
  • Boot timeouts (did not become ready within 180s, tunnel_*) — real failures; another ~180s retry usually fails the same way and is worth surfacing.

Testing

  • New co-located unit test pins the predicate to the real server messages (guards against the marker drifting).
  • bun test on the new file passes; bun run fmt clean.

Summary by cubic

Auto-retries transient SANDBOX_START errors so sandboxes recover without a page refresh, and fixes task-board tilt by detecting real lane changes only.

  • Bug Fixes
    • Sandbox start: Retry server-marked “retry shortly” errors in-place via @tanstack/react-query (up to 6 attempts with backoff to 5s). The mutation stays pending so the “Booting…” overlay holds. Added a unit test to pin the retry predicate to the server messages.
    • Task board: Detect lane changes by column using data-flip-lane, so horizontal layout shifts don’t tilt every card. Added the attribute to task cards.

Written for commit 92b1936. Summary will update on new commits.

Review in cubic

Pedro França added 2 commits July 24, 2026 13:01
FLIP inferred a lane change from horizontal delta (dx > 8px). A board-wide
sideways shift (scrollbar toggling, centered row re-centering) moves every card,
so all cards tilted at once and the laneOrder stagger delayed cleanup to ~1.7s.
Detect lane changes by the card's actual column (data-flip-lane) instead.
…efresh

Concurrency-transient starts (lifecycle transition in progress / advisory
lock busy) surfaced a 500 to the frontend that the user had to clear by
refreshing. The server already tags these with a 'retry shortly' marker;
retry them in-place via react-query so the booting overlay holds instead of
flipping to an error state.
@pedrofrxncx
pedrofrxncx enabled auto-merge (squash) July 24, 2026 16:10
@pedrofrxncx
pedrofrxncx merged commit 43259bb into main Jul 24, 2026
14 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/sandbox-start-retry-transient branch July 24, 2026 16:14
decocms Bot pushed a commit that referenced this pull request Jul 24, 2026
PR: #5195 fix(sandbox): auto-retry transient SANDBOX_START failures without a refresh
Bump type: patch

- decocms (apps/api/package.json): 4.123.1 -> 4.123.2

Deploy-Scope: web
pedrofrxncx pushed a commit that referenced this pull request Jul 27, 2026
#5240)

Reverts #5112 (share agent sandboxes by branch), #5116 (always share
agent sandboxes) and #5132 (use shared staging branch), restoring the
pre-#5112 behaviour: hosted agent sandboxes are per-user again, and a
new GitHub-backed thread gets a generated branch instead of `staging`.

Reconstructed against current paths rather than reverted: #5120 split
apps/mesh into apps/api + apps/web and hoisted branch-name.ts,
runtime-defaults.ts and thread/schema.ts into packages/shared, and #5174
deleted vm-events.ts outright, so none of the three commits reverse-apply.

Core change: SandboxId goes back to a flat `{ userId, projectRef }` and
sandboxIdKey back to `userId:projectRef`, so every hosted claim handle
changes. Live shared claims must be drained BEFORE this deploys.

Also reverted, because they only exist inside the shared model:
- #5225 withoutLegacyAgentSandboxEntries — left in place it would strip
  the sandboxMap entries the reverted server writes back, leaving
  shouldAutoStart permanently true (silent, compiles fine)
- #5219 resolveSharedThreadVm and the shared-scope branch
- #5183 stale-provisioning reset (lived inside the deleted storage)

Deliberately preserved:
- migrations 137/138 and their index.ts entries — Kysely's
  #ensureNoMissingMigrations runs unconditionally, so deleting an applied
  migration crash-loops every pod. The tables are dropped by a follow-up
  forward migration after the drain, not by this commit.
- #5114/#5118 withClaimGitLock, #5126 org-context guard, #5143 analytics
  gate, #5171 owner-keyed thread graft, #5195/#5207/#5210/#5221 client
  auto-retry, the daemon status-code train and the settings-validation train
- #5112's org-fs least-privilege narrowing and the start dedup key fix
- #5116's squashed queue-tray pluralization (en + pt-br)
- the remote-branch-name validations #5132 deleted, since this restores
  the dynamic origin/HEAD lookup that made them load-bearing

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Pedro França <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant