From a501860d63e8b571bad613cc7a13da5c66261578 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Thu, 21 Mar 2024 21:05:18 -0400 Subject: [PATCH] test_runner: don't await the same promise for each test Prior to this commit, each top level test awaited the same global promise for setting up test reporters. This commit updates the logic to only await the promise the first time it is encountered. PR-URL: https://github.com/nodejs/node/pull/52185 Refs: https://github.com/nodejs/node/pull/47164 Reviewed-By: Luigi Pinca Reviewed-By: Chemi Atlow --- lib/internal/test_runner/harness.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/internal/test_runner/harness.js b/lib/internal/test_runner/harness.js index 0e48d8f2a36857..3a00e5a3fcceab 100644 --- a/lib/internal/test_runner/harness.js +++ b/lib/internal/test_runner/harness.js @@ -233,7 +233,11 @@ function getGlobalRoot() { } async function startSubtest(subtest) { - await reportersSetup; + if (reportersSetup) { + // Only incur the overhead of awaiting the Promise once. + await reportersSetup; + reportersSetup = undefined; + } const root = getGlobalRoot(); if (!root.harness.bootstrapComplete) {