summaryrefslogtreecommitdiff
path: root/test/parallel/test-child-process-fork-abort-signal.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-child-process-fork-abort-signal.js')
-rw-r--r--test/parallel/test-child-process-fork-abort-signal.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/parallel/test-child-process-fork-abort-signal.js b/test/parallel/test-child-process-fork-abort-signal.js
index 9982444c42..b963306fb1 100644
--- a/test/parallel/test-child-process-fork-abort-signal.js
+++ b/test/parallel/test-child-process-fork-abort-signal.js
@@ -21,6 +21,26 @@ const { fork } = require('child_process');
}));
process.nextTick(() => ac.abort());
}
+
+{
+ // Test aborting with custom error
+ const ac = new AbortController();
+ const { signal } = ac;
+ const cp = fork(fixtures.path('child-process-stay-alive-forever.js'), {
+ signal
+ });
+ cp.on('exit', mustCall((code, killSignal) => {
+ strictEqual(code, null);
+ strictEqual(killSignal, 'SIGTERM');
+ }));
+ cp.on('error', mustCall((err) => {
+ strictEqual(err.name, 'AbortError');
+ strictEqual(err.cause.name, 'Error');
+ strictEqual(err.cause.message, 'boom');
+ }));
+ process.nextTick(() => ac.abort(new Error('boom')));
+}
+
{
// Test passing an already aborted signal to a forked child_process
const signal = AbortSignal.abort();
@@ -37,6 +57,23 @@ const { fork } = require('child_process');
}
{
+ // Test passing an aborted signal with custom error to a forked child_process
+ const signal = AbortSignal.abort(new Error('boom'));
+ const cp = fork(fixtures.path('child-process-stay-alive-forever.js'), {
+ signal
+ });
+ cp.on('exit', mustCall((code, killSignal) => {
+ strictEqual(code, null);
+ strictEqual(killSignal, 'SIGTERM');
+ }));
+ cp.on('error', mustCall((err) => {
+ strictEqual(err.name, 'AbortError');
+ strictEqual(err.cause.name, 'Error');
+ strictEqual(err.cause.message, 'boom');
+ }));
+}
+
+{
// Test passing a different kill signal
const signal = AbortSignal.abort();
const cp = fork(fixtures.path('child-process-stay-alive-forever.js'), {