-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Closed
Labels
child_processIssues and PRs related to the child_process subsystem.Issues and PRs related to the child_process subsystem.
Description
- Version: v15.5.0, v15.8.0 (works fine on v15.6, v15.7)
- Platform: macOS 10.15.7
- Subsystem: child_process
What steps will reproduce the bug?
Create a child process using spawn, and abort the controller. The signal doesn't abort child process.
How often does it reproduce? Is there a required condition?
This occurs every time, while running the following file:
const { spawn } = require('child_process');
const ac = new AbortController();
const { signal } = ac;
const cp = spawn(process.execPath, ['./infinity-demo.js'], { signal });
const stillRunningTimeout = setTimeout(() => { console.log('still running!'); cp.kill('SIGTERM'); }, 5000);
cp.on('exit', () => { clearTimeout(stillRunningTimeout); console.log('exited') });
cp.on('error', (e) => console.log('AN ERROR HAS HAPPENED', e.name));
setTimeout(()=>ac.abort(),5);
This is infinity-demo.js:
setInterval(()=>{},1000);
What is the expected behaviour?
The cp should die correctly, with the program printing:
AN ERROR HAS HAPPENED AbortError
exited
What do you see instead?
The cp still running (even though it emits an error) with the program printing:
AN ERROR HAS HAPPENED AbortError
still running!
exited
Additional information
This works correctly on 15.6, 15.7 but fails on 15.5 and 15.8. I believe that the tests missed this because they run on short-lived tasks (echo
etc.) that die anyway, and in addition the cp still emits the error.
I'd be happy to provide a PR for this.
sindresorhus and MoLow
Metadata
Metadata
Assignees
Labels
child_processIssues and PRs related to the child_process subsystem.Issues and PRs related to the child_process subsystem.