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 <benjamingr@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
1 parent ab130e9 commit c3b1167

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,24 @@ const execOpts = { encoding: 'utf8', shell: true };
5454
constac=newAbortController();
5555
const{ signal }=ac;
5656

57-
constcallback=common.mustCall((err)=>{
57+
constfirstCheck=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+
constsecondCheck=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)