Skip to content

Commit d5d56ec

Browse files
Trottdanielleadams
authored andcommitted
test: add test for reused AbortController with execfile()
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]>
1 parent 190ddce commit d5d56ec

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

test/parallel/test-child-process-execfile.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,24 @@ const execOpts = { encoding: 'utf8', shell: true };
5353
const ac = new AbortController();
5454
const { signal } = ac;
5555

56-
const callback = common.mustCall((err) => {
56+
const firstCheck = common.mustCall((err) => {
5757
assert.strictEqual(err.code, 'ABORT_ERR');
5858
assert.strictEqual(err.name, 'AbortError');
59+
assert.strictEqual(err.signal, undefined);
60+
});
61+
62+
const secondCheck = common.mustCall((err) => {
63+
assert.strictEqual(err.code, null);
64+
assert.strictEqual(err.name, 'Error');
65+
assert.strictEqual(err.signal, 'SIGTERM');
5966
});
60-
execFile(process.execPath, [echoFixture, 0], { signal }, callback);
67+
68+
execFile(process.execPath, [echoFixture, 0], { signal }, (err) => {
69+
firstCheck(err);
70+
// Test that re-using the aborted signal results in immediate SIGTERM.
71+
execFile(process.execPath, [echoFixture, 0], { signal }, secondCheck);
72+
});
73+
6174
ac.abort();
6275
}
6376

0 commit comments

Comments
 (0)