Skip to content

fix: fall back to tar install without hanging when package-manager install fails - #114

Open
zkochan wants to merge 2 commits into
mainfrom
tar-fallback
Open

fix: fall back to tar install without hanging when package-manager install fails#114
zkochan wants to merge 2 commits into
mainfrom
tar-fallback

Conversation

@zkochan

@zkochan zkochan commented Jul 30, 2026

Copy link
Copy Markdown
Member

Problem

When `--method=package-manager` installation failed (e.g. `ERR_PNPM_TARBALL_INTEGRITY` in CI), the fallback to the tar method ran and succeeded — but the process never exited, so CI jobs hung until killed by a 10-minute no-output timeout, making the whole install look like a failure.

Two separate leaks kept the event loop alive:

  1. On the pnpm failure path, `installWithPnpm` never called `global'finishWorkers'`, leaving pnpm's worker threads running.
  2. `fetchNode` (`@pnpm/node.fetcher`) also runs actions in pnpm workers, and nothing on the tar path terminated them — so even a successful tar install that downloaded Node.js left the process hanging (reproduced with `--method tar` on an unmodified flow).

There was also no upper bound on how long the package-manager method could take: if pnpm hung instead of throwing, the tar fallback was never reached.

Changes

  • `install-with-pnpm.ts`: wrap `install.handler` in `try/finally` so `finishWorkers()` and `stopReporting()` run whether the installation succeeds, fails, or is aborted.
  • `install.ts`: terminate pnpm workers in a `finally` when `installVersion` completes, regardless of installation method (covers the `fetchNode` workers).
  • `install.ts`: race the package-manager installation against a 60-second timeout. On timeout, an `AbortSignal` is triggered, pnpm's workers are terminated, and installation falls back to the tar method.
  • The abort signal is checked before `renameOverwrite`, so a slow registry install that finishes after the timeout can never overwrite the version directory installed by the tar fallback.
  • Print the reason when falling back to the tar method instead of failing silently.

Verification (run from the compiled bundle with an isolated `BVM_GLOBALS_DIR`)

Scenario Before After
pnpm fails fast (bad lockfile path) fallback ran, process hung fallback + install in 43s, clean exit
pnpm hangs (registry → dead port) no fallback at all abort at 60s, tar install done at ~1m30s, clean exit
`--method tar` with Node.js download install done in 28s, process hung forever clean exit in 29s

🤖 Generated with Claude Code

zkochan and others added 2 commits July 30, 2026 17:31
…stall fails

- Terminate pnpm's workers and stop the reporter even when the registry
  installation fails, so the process can exit after the tar fallback
  completes (previously CI jobs hung until killed by a no-output timeout).
- Abort the package-manager installation if it takes longer than 60
  seconds and fall back to installing from a tar file.
- Print the reason when falling back to the tar method.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
fetchNode also runs actions in pnpm workers, so even a tar-method
installation that downloads Node.js left the process hanging after
completion. Terminate the workers when installVersion finishes,
regardless of the installation method.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant