test: account for truthy signal in flaky async_hooks tests

When the spawned child process gets closed with a signal, the exit code
is not set and that is why the exit code assertion was failing. This
change adjusts the test to check the signal and if it is truthy, it
doesn't assert the exit code and instead logs the signal and continues
the rest of the assertions.

Refs: https://github.com/nodejs/node/issues/58463#issuecomment-2911460454
Refs: https://github.com/nodejs/node/issues/58199
Refs: https://github.com/nodejs/node/issues/58463
Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/58478
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Darshan Sen authored and GitHub committed 2025-05-29 07:40:11 +00:00
1 parent 411495ee93
commit 7ce82ad1de
2 files changed
+12 -4

No files matched your search

@@ -52,8 +52,12 @@ if (process.argv[2] === 'child') {
child.stderr.on('data', (d) => { errData = Buffer.concat([ errData, d ]); });
child.stdout.on('data', (d) => { outData = Buffer.concat([ outData, d ]); });
child.on('close', common.mustCall((code) => {
assert.strictEqual(code, 1);
child.on('close', common.mustCall((code, signal) => {
if (signal) {
console.log(`Child closed with signal: ${signal}`);
} else {
assert.strictEqual(code, 1);
}
assert.match(outData.toString(), heartbeatMsg,
'did not crash until we reached offending line of code ' +
`(found ${outData})`);
+6 -2
View File
@@ -55,8 +55,12 @@ if (process.argv[2] === 'child') {
child.stderr.on('data', (d) => { errData = Buffer.concat([ errData, d ]); });
child.stdout.on('data', (d) => { outData = Buffer.concat([ outData, d ]); });
child.on('close', common.mustCall((code) => {
assert.strictEqual(code, 1);
child.on('close', common.mustCall((code, signal) => {
if (signal) {
console.log(`Child closed with signal: ${signal}`);
} else {
assert.strictEqual(code, 1);
}
assert.match(outData.toString(), heartbeatMsg,
'did not crash until we reached offending line of code ' +
`(found ${outData})`);