forked from nodejs/node-core-test
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: avoid swallowing of asynchronously thrown errors
Fixes: nodejs/node#44612 PR-URL: nodejs/node#45264 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> (cherry picked from commit 06603c44a5b0e92b1a3591ace467ce9770bf9658)
- Loading branch information
1 parent
f2815af
commit cff397a
Showing
5 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// https://github.com/nodejs/node/blob/06603c44a5b0e92b1a3591ace467ce9770bf9658/test/fixtures/test-runner/extraneous_set_immediate_async.mjs | ||
import test from '#node:test' | ||
|
||
test('extraneous async activity test', () => { | ||
setImmediate(() => { throw new Error() }) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// https://github.com/nodejs/node/blob/06603c44a5b0e92b1a3591ace467ce9770bf9658/test/fixtures/test-runner/extraneous_set_timeout_async.mjs | ||
import test from '#node:test' | ||
|
||
test('extraneous async activity test', () => { | ||
setTimeout(() => { throw new Error() }, 100) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// https://github.com/nodejs/node/blob/06603c44a5b0e92b1a3591ace467ce9770bf9658/test/parallel/test-runner-extraneous-async-activity.js | ||
'use strict' | ||
require('../common') | ||
const fixtures = require('../common/fixtures') | ||
const assert = require('assert') | ||
const { spawnSync } = require('child_process') | ||
|
||
{ | ||
const child = spawnSync(process.execPath, [ | ||
'--test', | ||
fixtures.path('test-runner', 'extraneous_set_immediate_async.mjs') | ||
]) | ||
const stdout = child.stdout.toString() | ||
assert.match(stdout, /^# pass 0$/m) | ||
assert.match(stdout, /^# fail 1$/m) | ||
assert.match(stdout, /^# cancelled 0$/m) | ||
assert.strictEqual(child.status, 1) | ||
assert.strictEqual(child.signal, null) | ||
} | ||
|
||
{ | ||
const child = spawnSync(process.execPath, [ | ||
'--test', | ||
fixtures.path('test-runner', 'extraneous_set_timeout_async.mjs') | ||
]) | ||
const stdout = child.stdout.toString() | ||
assert.match(stdout, /^# pass 0$/m) | ||
assert.match(stdout, /^# fail 1$/m) | ||
assert.match(stdout, /^# cancelled 0$/m) | ||
assert.strictEqual(child.status, 1) | ||
assert.strictEqual(child.signal, null) | ||
} |