Skip to content

sandbox: async clone with polling (20-min timeout)#52

Merged
neenaoffline merged 1 commit intomainfrom
async-clone
Mar 21, 2026
Merged

sandbox: async clone with polling (20-min timeout)#52
neenaoffline merged 1 commit intomainfrom
async-clone

Conversation

@neenaoffline
Copy link
Member

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.ts

  • POST /clone now returns immediately with { status: "cloning", slug } and runs the clone in the background
  • New GET /clone/status/:slug?commitish= endpoint for polling
  • Clone jobs tracked in-memory with dedup (same repo+commitish reuses existing job)
  • Clone timeout increased to 20 minutes
  • Finished jobs cleaned up after 10 minutes
  • Failed jobs can be retried

client.ts

  • clone() now: kicks off via POST /clone, then polls GET /clone/status every 2s until ready/failed/timeout
  • 20-minute overall timeout
  • Cached repos return instantly (no polling)
  • Progress logged during polling

Backward compatible

The client handles both the new async flow and immediate ready responses (for cached repos), so no coordination needed between deploy of client and worker.

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
@neenaoffline neenaoffline merged commit 2a8a43b into main Mar 21, 2026
2 checks passed
@neenaoffline neenaoffline deleted the async-clone branch March 21, 2026 19:41
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