Skip to content

feat(vercel-sandbox): fix resume race-condition#97

Merged
marc-vercel merged 2 commits intonamed-sandboxesfrom
fix-resume-race-condition
Mar 17, 2026
Merged

feat(vercel-sandbox): fix resume race-condition#97
marc-vercel merged 2 commits intonamed-sandboxesfrom
fix-resume-race-condition

Conversation

@marc-vercel
Copy link
Collaborator

@marc-vercel marc-vercel commented Mar 17, 2026

Fix resume race-condition: ensure that when we call withResume multiple times, we only have one request in-fight.

For example, we were having a race condition and created two active sessions:

❯ sandbox create
  ✅ Sandbox coral-sour-iguana-jroMkL created.
     │ team: marc-codina-enhanced-vtest314
     ╰ project: my-sandbox-app
  ❯ sandbox stop coral-sour-iguana-jroMkL
  ✔ Stopping sandbox coral-sour-iguana-jroMkL
  ❯ sandbox ssh coral-sour-iguana-jroMkL
  $ sh
  ▲ /vercel/sandbox/ sandbox session list coral-sour-iguana-jroMkL
  sh: sandbox: command not found
  ▲ /vercel/sandbox/ sandbox session list coral-sour-iguana-jro^CL
  ▲ /vercel/sandbox/ exit
  exit

  ╰▶ connection to ▲ coral-sour-iguana-jroMkL closed.
  ❯ sandbox sessions list coral-sour-iguana-jroMkL
  ID                                 STATUS    CREATED        MEMORY   VCPUS   RUNTIME   TIMEOUT        DURATION
  sbx_1SMyrcBI54UQSPyRB9wPF6PCqOx2   running   1 minute ago   4096     2       node24    in 4 minutes   -
  sbx_OF2yUnDjZyiYhOaA90JKLu3rUa6c   running   1 minute ago   4096     2       node24    in 4 minutes   -
  sbx_UidxVjezS5n7vB8fc8WkxgtVQgyE   stopped   1 minute ago   4096     2       node24    in 4 minutes   12.029s

Root cause of the race-condition:

When doing a sandbox ssh, we run two operations concurrently via Promise.race:

  • checkIfServerInstalled() → calls sandbox.runCommand()
  • installServerBinary() → calls sandbox.writeFiles()

@vercel
Copy link

vercel bot commented Mar 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sandbox-sdk Ready Ready Preview Mar 17, 2026 2:01pm

@marc-vercel marc-vercel requested review from AndyW22 and QuiiBz March 17, 2026 14:01
@marc-vercel marc-vercel marked this pull request as ready for review March 17, 2026 14:02
@marc-vercel marc-vercel merged commit 9212ac9 into named-sandboxes Mar 17, 2026
10 of 11 checks passed
@marc-vercel marc-vercel deleted the fix-resume-race-condition branch March 17, 2026 14:16
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.

2 participants