mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
child_process: add AbortSignal support
PR-URL: https://github.com/nodejs/node/pull/36308 Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
5477969555
commit
20de5f7efc
4 files changed
+61
-3
No files matched your search
@@ -114,6 +114,7 @@ if (!common.isMainThread) {
|
||||
'Internal Binding performance',
|
||||
'Internal Binding symbols',
|
||||
'Internal Binding worker',
|
||||
'NativeModule internal/streams/add-abort-signal',
|
||||
'NativeModule internal/streams/duplex',
|
||||
'NativeModule internal/streams/passthrough',
|
||||
'NativeModule internal/streams/readable',
|
||||
|
||||
@@ -7,6 +7,7 @@ const { getSystemErrorName } = require('util');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const fixture = fixtures.path('exit.js');
|
||||
const echoFixture = fixtures.path('echo.js');
|
||||
const execOpts = { encoding: 'utf8', shell: true };
|
||||
|
||||
{
|
||||
@@ -45,3 +46,16 @@ const execOpts = { encoding: 'utf8', shell: true };
|
||||
// Verify the shell option works properly
|
||||
execFile(process.execPath, [fixture, 0], execOpts, common.mustSucceed());
|
||||
}
|
||||
|
||||
{
|
||||
// Verify that the signal option works properly
|
||||
const ac = new AbortController();
|
||||
const { signal } = ac;
|
||||
|
||||
const callback = common.mustCall((err) => {
|
||||
assert.strictEqual(err.code, 'ABORT_ERR');
|
||||
assert.strictEqual(err.name, 'AbortError');
|
||||
});
|
||||
execFile(process.execPath, [echoFixture, 0], { signal }, callback);
|
||||
ac.abort();
|
||||
}
|
||||
Reference in new issue
Block a user