From 328755341db9df3ec1740c9801971454aaf8d9c1 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Thu, 11 Apr 2024 21:05:33 -0400 Subject: [PATCH] test_runner: don't exceed call stack when filtering This commit updates filteredRun() to call postRun() after a microtask instead of synchronously. Currently, if approximately 1,545 subtests are filtered, enough synchronous calls can be made to cause a call stack exceeded exception. PR-URL: https://github.com/nodejs/node/pull/52488 Reviewed-By: Yagiz Nizipli Reviewed-By: Chemi Atlow Reviewed-By: Benjamin Gruenbaum Reviewed-By: Marco Ippolito Reviewed-By: Moshe Atlow --- lib/internal/test_runner/test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index 8bf63654bf1f21..9e8851bb55e62c 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -29,6 +29,7 @@ const { } = primordials; const { getCallerLocation } = internalBinding('util'); const { addAbortListener } = require('internal/events/abort_listener'); +const { queueMicrotask } = require('internal/process/task_queues'); const { AsyncResource } = require('async_hooks'); const { AbortController } = require('internal/abort_controller'); const { @@ -673,7 +674,7 @@ class Test extends AsyncResource { this.pass(); this.subtests = []; this.report = noop; - this.postRun(); + queueMicrotask(() => this.postRun()); } async run() {