Skip to content

fix: fail the run when a task cannot be spawned with --continue-on-error - #270

Open
RClaudiuM wants to merge 1 commit into
bcomnes:masterfrom
RClaudiuM:fix/267-continue-on-error-spawn-errors
Open

RClaudiuM wants to merge 1 commit into
bcomnes:masterfrom
RClaudiuM:fix/267-continue-on-error-spawn-errors

Conversation

@RClaudiuM

Copy link
Copy Markdown

Fixes #267

With --continue-on-error, the rejection handler in lib/run-tasks.js dropped spawn errors (for example spawn /nonexistent/npm ENOENT) without storing them, so done() resolved and the CLI exited 0 even though no task ran.

The handler now records the error before deciding whether to abort. Without -c (or with --race) nothing changes. With -c the remaining tasks still run, and the run rejects at the end, the same way it does when a task exits with a non-zero code.

Tests

Added if tasks could not be spawned with --continue-on-error to test/fail.js. It covers the Node API (sequential and parallel, asserting the ENOENT rejection) and npm-run-all -c, run-s -c and run-p -c with a missing --npm-path.

  • Before the fix: all 5 new tests fail (the run resolves).
  • After the fix: they pass. npm run check and the full node --test suite pass.

Manual check from test-workspace:

$ node ../bin/npm-run-all/index.js -p -c --npm-path /nonexistent/npm test-task:append:a test-task:append:b; echo "exit=$?"
# before: exit=0, no output
# after:
ERROR: spawn /nonexistent/npm ENOENT
exit=1

With --continue-on-error, a task whose process failed to spawn (e.g. ENOENT for the npm path) was dropped without recording the error, so the run resolved and the CLI exited 0 even though no task ran. Record the error and keep running the remaining tasks, so the run rejects at the end like it does for tasks that exit with a non-zero code.
@bcomnes

bcomnes commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Looks acceptable from a quick skim

@RClaudiuM

Copy link
Copy Markdown
Author

The one red job (windows-latest, Node 24) is test/parallel.js:286, the --max-parallel 2 ordering test: it got babcac, i.e. a finished and c started before b wrote its second character. All three tasks exit 0 there, so it never reaches the error callback this PR changes, and the other 9 jobs pass. A re-run should clear it.

@bcomnes

bcomnes commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Unfortunately there seems to be some kind long running windows race condition. I haven't been able to identify it. Sometimes ci needs to re-run.

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.

--continue-on-error swallows spawn errors: run exits 0 when no task could start

2 participants