feat(sandbox): add idempotent retry for sandbox creation and connection - #457
Merged
Conversation
- Add idempotency key auto-generation (crypto.randomUUID) with Idempotency-Key header
- Add _retryCall method wrapping create/connect with configurable maxRetries
- Retry on 408/5xx server errors and network errors (timeout, connection refused, etc.)
- Configurable via maxRetries option or SANDBOX_RETRY_MAX env var
- Add Sandbox.create({ idempotencyKey }) optional parameter
- Add integration test for Git clone timeout retry scenario
- Add sandbox_idempotency_retry example
- Add SANDBOX_RETRY_MAX to .env.example
There was a problem hiding this comment.
Review Summary
Found five concrete issues affecting supported Node.js versions, public retry configuration and typings, test reliability, and example accuracy.
Validation note: reviewed and rechecked head 50eaa85c2af3847361d759f94a0e20e9fc4c6fb0. The focused suite could not run because the mounted workspace has no usable local test dependencies (mocha: Permission denied, then no local module).
…rrors - Add exponential backoff with jitter (500ms → 10s) between retries - Integration test: re-throw non-retryable 4xx errors instead of logging
- Replace crypto.randomUUID() with crypto.randomBytes(16) for Node 6+ compat - Add maxRetries to sandboxClientOptions() so Sandbox.create() respects it - Add idempotencyKey to TypeScript SandboxCreateOptions - Add maxRetries to TypeScript SandboxClientOptions - Fix example to call Create twice with same idempotency key
…sandboxes Previously sb1 was killed but sb2 leaked if the two Create calls returned different sandbox IDs.
miclle
reviewed
Jul 29, 2026
…idempotency key stable Check err.code for standard Node.js network error codes (ECONNREFUSED, ECONNRESET, etc.) in addition to message-based detection. Add unit tests for retry behavior and idempotency key stability across retries. Use GIT_REPO_URL in integration test.
…AGAIN generateIdempotencyKey now outputs RFC 9562 UUID v4 format. normalizeMaxRetries validates non-integer/negative values from both options and SANDBOX_RETRY_MAX environment variable. EAI_AGAIN added to retryable network error codes. Remove git clone integration test.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #457 +/- ##
==========================================
- Coverage 93.41% 93.32% -0.10%
==========================================
Files 14 14
Lines 2006 2097 +91
==========================================
+ Hits 1874 1957 +83
- Misses 132 140 +8
🚀 New features to boost your workflow:
|
miclle
approved these changes
Jul 29, 2026
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.
Idempotency-Keyheader for Create_retryCallmethod wrapping Create and Connect, retries on 408/5xx server errors and network errorsmaxRetriesviamaxRetriesoption orSANDBOX_RETRY_MAXenv var (default 5)Sandbox.create({ idempotencyKey })optional parameterexamples/sandbox_idempotency_retry.js