Skip to content

Commit bc5af1c

Browse files
panvanodejs-github-bot
authored andcommitted
test: wait for shared-isolate Worker exit
Ten thousand non-blocking loop turns can finish before the Worker has started. Use a thirty-second deadline and yield between turns while waiting for its exit, preserving the expected exit-code assertion. Refs: nodejs/reliability#1687 Signed-off-by: Filip Skokan <panva.ip@gmail.com> Assisted-by: Codex PR-URL: #66722 Refs: nodejs/reliability#1686 Refs: nodejs/reliability#1690 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>
1 parent 0c2949d commit bc5af1c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎test/cctest/test_environment_shared_isolate.cc‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,13 @@ TEST_P(SharedIsolateTest, EnvironmentsComeAndGoWhileSiblingsRun) {
354354
" return 0;\n"
355355
"})()"),
356356
0);
357-
for (int turn = 0; turn < 10000; turn++) {
357+
// Loop turns do not bound Worker startup time. Yield to the Worker and
358+
// allow it to finish even when the main thread pumps the loop quickly.
359+
const uint64_t deadline = uv_hrtime() + 30ULL * 1000 * 1000 * 1000;
360+
while (uv_hrtime() < deadline) {
358361
PumpLoop(1);
359362
if (EvaluateInt(third.get(), "state.workerExit") == 7) break;
363+
uv_sleep(1);
360364
}
361365
EXPECT_EQ(EvaluateInt(third.get(), "state.workerExit"), 7);
362366
}

0 commit comments

Comments
 (0)