From c6e6ff3b0adde362c57b641618149ca25244962d Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 14 Sep 2025 01:38:49 -0700 Subject: [PATCH] test: ensure message event fires in worker message port test Add assertion to verify that the MessagePort's message event is actually emitted in test-worker-message-port-infinite-message-loop.js. Previously, the test could pass even if the event was not fired. --- .../test-worker-message-port-infinite-message-loop.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/parallel/test-worker-message-port-infinite-message-loop.js b/test/parallel/test-worker-message-port-infinite-message-loop.js index 0cd1cc06802055..88820ac8918476 100644 --- a/test/parallel/test-worker-message-port-infinite-message-loop.js +++ b/test/parallel/test-worker-message-port-infinite-message-loop.js @@ -27,3 +27,14 @@ port2.postMessage(0); // This is part of the test -- the event loop should be available and not stall // out due to the recursive .postMessage() calls. setTimeout(common.mustCall(), 0); + +// Assert that the 'message' handler was actually called. +// +// We do not want to assert a specific call count, so common.mustCall cannot be +// used in the port1.on('message' callback directly. +process.once( + 'beforeExit', + common.mustCall(() => { + assert(count > 0, 'count should be greater than 0'); + }) +);