The SANDBOX_SNAPSHOTTING error occurs when a request lands on a Sandbox whose current session is in the middle of creating a snapshot. The session no longer accepts commands and will stop once the snapshot finishes. This happens automatically for persistent sandboxes on stop, and on demand when you call sandbox.snapshot().
SANDBOX_SNAPSHOTTING:
Unprocessable Entity
I'm encountering an error and reviewing the docs at https://vercel.com/docs/errors/SANDBOX_SNAPSHOTTING.md to understand what's happening.
Please help me resolve this by:
1. **Suggest the fix**: Analyze my codebase context and propose what needs to be changed to resolve this error. If you do not have access to my codebase, ask me for the codebase and try to fix the error based on the information you have.
2. **Explain the root cause**: Break down why this error occurred:
- What was the code actually doing vs. what it needed to do?
- What conditions triggered this specific error?
- What misconception or oversight led to this?
3. **Teach the concept**: Help me understand the underlying principle:
- Why does this error exist and what is it protecting me from?
- What's the correct mental model for this concept?
- How does this fit into the broader framework/language design?
4. **Show warning signs**: Help me recognize this pattern in the future:
- What should I look out for that might cause this again?
- Are there similar mistakes I might make in related scenarios?
- What code smells or patterns indicate this issue?
5. **Discuss alternatives**: Explain if there are different valid approaches and their trade-offs
My goal is to fix the immediate issue while building lasting understanding so I can avoid and resolve similar errors independently in the future.
To troubleshoot this error, follow these steps:
- Wait for the snapshot to finish, then resume: This is a transient state. For a persistent Sandbox, the snapshot is the saved filesystem the next session resumes from. Once it's done, call
Sandbox.get({ name }) (or run any SDK command) to start a new session.
- Check whether your code is racing
snapshot(): If one path calls sandbox.snapshot() while another path is still issuing commands, the second path can see SANDBOX_SNAPSHOTTING. Coordinate the two paths or guard them with the status accessor.
- Inspect the Sandbox history: Navigate to the Sandboxes dashboard, select the Sandbox, and check the history section to see what triggered the snapshot.