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 <yagiz.nizipli@sentry.io>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
This commit is contained in:
cjihrig 2024-04-11 21:05:33 -04:00 committed by Node.js GitHub Bot
parent 77424b05e9
commit 11f8765475

View File

@ -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() {