fix: skip wait_for_status when Vercel sandbox is in a terminal state#3410
Conversation
|
Self-review note: in the original commit I included |
seratch
left a comment
There was a problem hiding this comment.
Approved. I validated the code path against the real Vercel Sandbox runtime as well as the focused unit coverage.
On PR head, resuming an already-running sandbox reconnected to the same sandbox immediately, and resuming a stopped sandbox recreated a new sandbox without waiting for the wait_for_status(RUNNING) timeout. As a control, the same stopped-resume scenario on origin/main still waited for the shortened timeout before recreating, which confirms this PR removes the intended delay.
I also confirmed the live SDK status values are pending, running, stopping, stopped, failed, aborted, and snapshotting, so limiting the wait path to pending matches the observed state model.
Summary
VercelSandboxClient.resume()calledwait_for_status(RUNNING)unconditionallyafter fetching an existing sandbox, even when the sandbox was already in a terminal
state (
stoppedorfailed). Since a terminal sandbox can never transition toRUNNING, this caused a ~45-second timeout before falling back to creating a newsandbox — wasting time on every resume after a sandbox had stopped.
This was noted by a maintainer with an
XXXcomment at the call site.Fix: check the current sandbox status before waiting:
running→ reconnect immediately, skip the waitpending/stopping) → wait as beforestopped/failed) → close and recreate immediatelyTest plan
test_vercel_resume_reconnects_existing_running_sandbox: sandbox alreadyrunningno longer callswait_for_status.test_vercel_resume_recreates_sandbox_after_wait_timeout: usespendingstatus so the wait path is actually exercised.
test_vercel_resume_waits_when_sandbox_in_transient_state(parametrized:pending,stopping): verifieswait_for_statusis still called for transient states.test_vercel_resume_recreates_sandbox_when_in_terminal_state(parametrized:stopped,failed): verifies immediate fallback with no wait.All 4587 tests pass (
make tests).Issue number
Checks
make lintandmake format