sandbox: async clone with polling (20-min timeout)#52
Merged
neenaoffline merged 1 commit intomainfrom Mar 21, 2026
Merged
Conversation
Large repos (e.g. git/git) time out during clone because the entire
clone+worktree setup runs synchronously within a single HTTP request
with a 120s timeout.
Changes:
worker.ts:
- POST /clone now kicks off the clone in the background and returns
immediately with { status: 'cloning', slug }
- New GET /clone/status/:slug?commitish= endpoint for polling
- Clone jobs are tracked in-memory with deduplication (same repo+
commitish reuses existing job)
- Finished jobs are cleaned up after 10 minutes
- Clone timeout increased to 20 minutes (CLONE_TIMEOUT_MS)
- If repo is already cloned, returns 'ready' immediately
- Failed jobs can be retried (new POST /clone replaces the failed job)
client.ts:
- clone() now: POST /clone to start, then polls GET /clone/status
every 2 seconds until ready/failed/timeout
- 20-minute overall timeout (CLONE_POLL_TIMEOUT_MS)
- Individual poll requests have 10s timeout (network resilience)
- Cached repos return instantly (no polling needed)
- Progress logged during polling
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.
Large repos (e.g.
git/git~200MB) time out during clone because the entire clone+worktree runs synchronously within one HTTP request with a 120s timeout.Changes
worker.tsPOST /clonenow returns immediately with{ status: "cloning", slug }and runs the clone in the backgroundGET /clone/status/:slug?commitish=endpoint for pollingclient.tsclone()now: kicks off viaPOST /clone, then pollsGET /clone/statusevery 2s until ready/failed/timeoutBackward compatible
The client handles both the new async flow and immediate
readyresponses (for cached repos), so no coordination needed between deploy of client and worker.