Resolving sandbox creation race conditions and duplicate requests
Last updated: March 24, 2026
If you're experiencing sandbox creation failures, you may be encountering a race condition caused by duplicate sandbox creation requests being sent simultaneously.
Common Error Messages
You might see errors such as:
SANDBOX_ALREADY_EXISTS(409)RATE_LIMIT_EXCEEDED(429)
Root Cause
This issue typically occurs when your application makes multiple simultaneous calls to create the same sandbox. Common scenarios include:
React Strict Mode in development environments, which intentionally runs effects twice
React hooks triggering multiple times during component re-renders
Rapid user interactions causing duplicate API calls
Platform-Side Fixes
Our team has implemented several fixes to handle race conditions more gracefully on the platform side. These improvements should prevent most instances of this issue, even when duplicate requests are made.
Preventing Duplicate Requests in Your Code
While the platform now handles most race conditions, you can also prevent duplicate requests in your application.
Primary Solution
The recommended approach is to use createIfNotExists() / create_if_not_exists() instead of create(). This method handles 409 conflicts gracefully by returning the existing sandbox.
const sandbox = await SandboxInstance.createIfNotExists({
name: "my-sandbox",
image: "blaxel/base-image:latest",
memory: 4096,
region: "us-pdx-1",
});sandbox = await SandboxInstance.create_if_not_exists({
"name": "my-sandbox",
"image": "blaxel/base-image:latest",
"memory": 4096,
"region": "us-pdx-1",
})In addition, you can also add optional client-side guardrails in your code.
Optional: Add Request Guards
Implement a guard mechanism to prevent multiple simultaneous creation attempts:
Use an
isCreatingflag to track when a sandbox creation is in progressCheck if a sandbox is already being created before making new requests
Implement proper loading states in your UI
Optional: Handle React Strict Mode
If you're using React Strict Mode in development:
Consider using
useEffectcleanup functions to cancel duplicate requestsImplement proper dependency arrays to prevent unnecessary re-runs
Use
useRefto track request status across re-renders
What to Do If You Still Experience Issues
If you continue to encounter sandbox creation race conditions after our recent fixes:
Note the sandbox ID and timestamp of the error
Check if you're making duplicate creation calls in your code
Contact support with the specific error details
Our team continues to monitor and improve race condition handling to ensure reliable sandbox creation.