From a7621d95ed88a36940930ebf4d54fea2913a0e74 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 202759bdbfe7ae..5f43e846f29585 100644 --- a/lib/internal/test_runner/harness.js +++ b/lib/internal/test_runner/harness.js @@ -225,7 +225,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) {