chore(sbx): recover the mount sandbox after a host pnpm install - #339
Open
HendrikThePendric wants to merge 1 commit into
Open
chore(sbx): recover the mount sandbox after a host pnpm install#339HendrikThePendric wants to merge 1 commit into
HendrikThePendric wants to merge 1 commit into
Conversation
A host `pnpm install` recreates node_modules under the container-local overlay, poisoning the sandbox's working directory so every command fails with getcwd errors. Drop the per-command self-heal line (itself a brick vector from a disrupted cwd), and instead have `pnpm sbx:mount` detect an unresponsive sandbox and restart its container, which re-establishes the overlay — a one-step recovery. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
🚀 Deployed on https://pr-339.event-visualizer.netlify.dhis2.org |
|
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.



What was wrong
The sandbox keeps its own fast copy of node_modules, mounted over the real one (reading node_modules over the host↔sandbox file share is about 2× slower). When you run
pnpm installon the host, it recreates node_modules and pulls that mount out from under the sandbox. After that, every command in the sandbox fails withgetcwd: Operation not permittedand the sandbox is stuck.Why we can't fully prevent it
node_modules has to live inside the shared folder (the project dir), so a host install that recreates it will always break the mount. The only way to avoid it is to drop the local copy — but that makes the test suite about 2× slower, so we keep it.
What was there before
On startup the sandbox re-applied the mount before every command, meant as a self-heal. It didn't actually help: once the folder is stuck, that command fails too, so it just made everything fail. It also added overhead on every command.
What we do now
Drop the per-command self-heal. Instead,
pnpm sbx:mountnotices when the sandbox is stuck and restarts it, which puts the mount back — so recovery is one command: runpnpm sbx:mountagain (add-- --continueto resume your session). The in-sandbox Claude also recognizes the stuck state (commands failing withgetcwdor missing-module errors) and tells you to do exactly that, so you're not left guessing.