Stop Playwright setup from deleting the package it just installed
Setting up the browser view failed on every container, and re-running it reproduced the same broken state, because the setup destroyed its own work. `install_packages` ran two `npm install --no-save` commands into /workspace, which has no package.json. With no manifest, npm treats the command line as the whole statement of what the tree should contain and prunes the rest, so installing `playwright` second removed the `@playwright/cli` installed first: "removed 3 packages", leaving an empty node_modules/@playwright/ behind playwright and playwright-core. That empty directory is exactly what the pane then reported as missing. The second install now names both specs; the first one is already present, so it costs nothing and is only there to stop npm pruning it. Two failures were waiting behind that one: Nothing in the tree ever configured the browser, so playwright-cli fell back to channel `chrome` — system Google Chrome — with the Chromium sandbox on. These containers forbid unprivileged user namespaces, so it aborted with "Failed to move to new namespace ... Operation not permitted"; on a base image without Google Chrome the same default failed as "Chromium distribution 'chrome' is not found". entrypoint.sh now seeds ~/.playwright/cli.config.json on every start, which is the only way to reach existing projects: ~/.playwright is inside the home volume, so an image copy would reach new projects only. The launch check passed for a configuration the viewer never uses. It launched bundled chromium with no channel, which resolves to chromium-headless-shell, while the viewer's config pins chrome-for-testing — the full chromium build, a separate download. A container could pass every check and still fail in the pane with 'Browser "chrome-for-testing" is not installed', which is what a stale chromium-1217 against a wanted chromium-1237 did. Chromium is now verified on both channels, the sandbox setting is stated rather than inherited from a default, and a failure names the channel. triple-c-playwright-heal repairs all of it on a container that is already broken, including the missing socat that makes the pane report "127.0.0.1 sent an invalid response" while the container side is perfectly healthy. It verifies by launching a browser rather than trusting the preceding steps — which is how the stale-revision case was found — and lives in /usr/local/bin so a fix to it can still reach an existing project. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -425,6 +425,32 @@ if [ -x /usr/local/bin/triple-c-open ]; then
|
||||
export BROWSER=/usr/local/bin/triple-c-open
|
||||
fi
|
||||
|
||||
# ── Playwright browser config ───────────────────────────────────────────────
|
||||
# Seed ~/.playwright/cli.config.json on every start.
|
||||
#
|
||||
# Without it `playwright-cli` resolves to channel `chrome` — system Google
|
||||
# Chrome — with the Chromium sandbox ON, and these containers do not permit
|
||||
# unprivileged user namespaces, so the browser aborts with "Failed to move to
|
||||
# new namespace ... Operation not permitted". On a base image that no longer
|
||||
# ships Google Chrome the same default fails the other way, with "Chromium
|
||||
# distribution 'chrome' is not found". One cause, two error messages, and
|
||||
# neither of them looks like a configuration problem.
|
||||
#
|
||||
# Seeded here rather than baked into the image because ~/.playwright is inside
|
||||
# the home volume: an image copy would reach new projects only, and every
|
||||
# existing project would stay broken forever. Written on every start from a
|
||||
# source outside the volume, the way CLAUDE_INSTRUCTIONS and the Mission
|
||||
# Control skills already are.
|
||||
#
|
||||
# --seed-config-only is the cheap path: no npm install, no browser download, no
|
||||
# apt, no verify launch, nothing over the network. It writes one small file if
|
||||
# it is absent and returns. Measured at ~2 ms. The heavier repairs stay
|
||||
# on-demand — run `triple-c-playwright-heal` with no arguments for those.
|
||||
if [ -x /usr/local/bin/triple-c-playwright-heal ]; then
|
||||
/usr/local/bin/triple-c-playwright-heal --seed-config-only --quiet || \
|
||||
echo "entrypoint: warning — playwright config seeding failed (browser view may not launch)"
|
||||
fi
|
||||
|
||||
# ── Scheduler setup ─────────────────────────────────────────────────────────
|
||||
SCHEDULER_DIR="/home/claude/.claude/scheduler"
|
||||
mkdir -p "$SCHEDULER_DIR/tasks" "$SCHEDULER_DIR/logs" "$SCHEDULER_DIR/notifications"
|
||||
|
||||
Reference in New Issue
Block a user