Skip to content

Commit c3b1167

Browse files
Trotttargos
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 ab130e9 commit c3b1167

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
@@ -54,11 +54,24 @@ const execOpts = { encoding: 'utf8', shell: true };
5454
const ac = new AbortController();
5555
const { signal } = ac;
5656

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

0 commit comments

Comments
 (0)