Skip to content

Commit

Permalink
test: add test for reused AbortController with execfile()
Browse files Browse the repository at this point in the history
Test that reusing an aborted AbortController with execfile() results in
immediate SIGTERM.

PR-URL: #36644
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Daijiro Wachi <[email protected]>
  • Loading branch information
Trott authored and danielleadams committed Jan 12, 2021
1 parent 190ddce commit d5d56ec
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/parallel/test-child-process-execfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,24 @@ const execOpts = { encoding: 'utf8', shell: true };
const ac = new AbortController();
const { signal } = ac;

const callback = common.mustCall((err) => {
const firstCheck = common.mustCall((err) => {
assert.strictEqual(err.code, 'ABORT_ERR');
assert.strictEqual(err.name, 'AbortError');
assert.strictEqual(err.signal, undefined);
});

const secondCheck = common.mustCall((err) => {
assert.strictEqual(err.code, null);
assert.strictEqual(err.name, 'Error');
assert.strictEqual(err.signal, 'SIGTERM');
});
execFile(process.execPath, [echoFixture, 0], { signal }, callback);

execFile(process.execPath, [echoFixture, 0], { signal }, (err) => {
firstCheck(err);
// Test that re-using the aborted signal results in immediate SIGTERM.
execFile(process.execPath, [echoFixture, 0], { signal }, secondCheck);
});

ac.abort();
}

Expand Down

0 comments on commit d5d56ec

Please sign in to comment.