fix(install): install camoufox-js@0.11.0 inside daemon package, not globally

Root cause: camoufox-browser@0.1.0 bundles camoufox-js@0.9.3.
When the daemon does 'import("camoufox-js")', Node.js resolves
the BUNDLED version (0.9.3) FIRST — not the global one.
Version 0.9.3 doesn't recognize the version.json format from
0.11.0, so it re-downloads the 298MB browser binary on EVERY
navigation command, causing timeout -> 'Empty response'.

Fix: instead of 'npm install -g camoufox-js@0.11.0' (which
Node ignores because bundled takes priority), use:
  npm install --prefix "$(npm root -g)/camoufox-browser" camoufox-js@0.11.0
This installs v0.11.0 INSIDE the daemon's own node_modules,
overriding the bundled 0.9.3.
This commit is contained in:
2026-06-13 19:25:46 +05:30
parent 05ec7d20b7
commit 74be39e0d5
2 changed files with 34 additions and 4 deletions

View File

@@ -222,14 +222,29 @@ install_camoufox_browser() {
return 0
fi
# Step 1: Install npm package
# Step 1: Install npm package (daemon)
info "Installing npm package (camoufox-browser@0.1.0)..."
npm install -g camoufox-browser@0.1.0 2>&1 | tail -3 || {
warn "npm install failed. Try manually: npm install -g camoufox-browser@0.1.0"
return 0
}
# Step 2: Download browser binary
# Step 2: Override bundled camoufox-js@0.9.3 with v0.11.0
# The daemon does: import("camoufox-js") — Node resolves this from
# the daemon's own node_modules/, NOT global node_modules.
# So a global install won't fix it — we must install inside the package.
info "Upgrading bundled camoufox-js to v0.11.0 (daemon dependency)..."
local cb_pkg
cb_pkg="$(npm root -g 2>/dev/null)/camoufox-browser"
if [ -d "$cb_pkg" ]; then
npm install --prefix "$cb_pkg" camoufox-js@0.11.0 2>&1 | tail -3 || {
warn "Failed to upgrade camoufox-js in $cb_pkg"
}
else
warn "Could not find camoufox-browser package directory at $cb_pkg"
fi
# Step 3: Download browser binary
info "Downloading Camoufox browser binary (~311MB)..."
npx --yes camoufox-js@0.11.0 fetch 2>&1 || {
warn "Download failed. Try manually: npx --yes camoufox-js@0.11.0 fetch"