From 5fba1e85230a13af6c566b87fb11710c78278c29 Mon Sep 17 00:00:00 2001 From: Antonio Duran Date: Thu, 29 Oct 2026 16:09:38 -0600 Subject: [PATCH] test: use spawnSyncAndAssert in nested async stack overflow test Signed-off-by: Antonio Duran --- ...t-async-hooks-stack-overflow-nested-async.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/test/parallel/test-async-hooks-stack-overflow-nested-async.js b/test/parallel/test-async-hooks-stack-overflow-nested-async.js index 779f8d75ae20..faa457e211fe 100644 --- a/test/parallel/test-async-hooks-stack-overflow-nested-async.js +++ b/test/parallel/test-async-hooks-stack-overflow-nested-async.js @@ -7,7 +7,7 @@ require('../common'); const assert = require('assert'); -const { spawnSync } = require('child_process'); +const { spawnSyncAndAssert } = require('../common/child_process'); if (process.argv[2] === 'child') { const { createHook } = require('async_hooks'); @@ -64,17 +64,12 @@ if (process.argv[2] === 'child') { } } else { // Parent process - spawn the child and check exit code - const result = spawnSync( + spawnSyncAndAssert( process.execPath, [__filename, 'child'], - { encoding: 'utf8', timeout: 30000 } + { encoding: 'utf8', timeout: 30000 }, + { + stdout: /SUCCESS: try-catch caught the stack overflow/, + }, ); - - // Should exit successfully (try-catch worked) - assert.strictEqual(result.status, 0, - `Expected exit code 0, got ${result.status}.\n` + - `stdout: ${result.stdout}\n` + - `stderr: ${result.stderr}`); - // Verify the error was handled by try-catch - assert.match(result.stdout, /SUCCESS: try-catch caught the stack overflow/); }