Skip to content

chore(sbx): recover the mount sandbox after a host pnpm install - #339

Open
HendrikThePendric wants to merge 1 commit into
masterfrom
chore/sbx-handle-node-modules-changes
Open

chore(sbx): recover the mount sandbox after a host pnpm install#339
HendrikThePendric wants to merge 1 commit into
masterfrom
chore/sbx-handle-node-modules-changes

Conversation

@HendrikThePendric

@HendrikThePendric HendrikThePendric commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

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 install on the host, it recreates node_modules and pulls that mount out from under the sandbox. After that, every command in the sandbox fails with getcwd: Operation not permitted and 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:mount notices when the sandbox is stuck and restarts it, which puts the mount back — so recovery is one command: run pnpm sbx:mount again (add -- --continue to resume your session). The in-sandbox Claude also recognizes the stuck state (commands failing with getcwd or missing-module errors) and tells you to do exactly that, so you're not left guessing.

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>
@dhis2-bot

Copy link
Copy Markdown
Contributor

🚀 Deployed on https://pr-339.event-visualizer.netlify.dhis2.org

@dhis2-bot
dhis2-bot temporarily deployed to netlify August 12, 2026 16:36 Inactive
@sonarqubecloud

Copy link
Copy Markdown

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.

3 participants