diff --git a/eslint/babel-eslint-parser/src/client.cjs b/eslint/babel-eslint-parser/src/client.cjs index a5e2ad74bda6..e08f99e935d9 100644 --- a/eslint/babel-eslint-parser/src/client.cjs +++ b/eslint/babel-eslint-parser/src/client.cjs @@ -72,18 +72,29 @@ exports.WorkerClient = class WorkerClient extends Client { [subChannel.port1], ); - Atomics.wait(this.#signal, 0, 0); - - let resp; - for (let i = 0; i < 100; i++) { - resp = WorkerClient.#worker_threads.receiveMessageOnPort( + let response; + let i = 0; + // Sometimes receiveMessageOnPort returns "undefined" instead of the + // actual response object. Try multiple times, with a timeout of 5ms + // on Atomic.wait starting from the second one. + do { + const wakeReason = Atomics.wait( + this.#signal, + 0, + i === 0 ? Infinity : 5, + ); + response = WorkerClient.#worker_threads.receiveMessageOnPort( subChannel.port2, ); - if (resp) break; - Atomics.wait(this.#signal, 1, 0, 5); - } - const message = resp.message; + if (i > 0 || !response) { + console.log( + `WORKER COMMUNICATION: i=${i}, wakeReason=${wakeReason}, hasResponse=${!!response}`, + ); + } + } while (!response && i++ < 100); + + const { message } = response; if (message.error) throw Object.assign(message.error, message.errorData); else return message.result; }); diff --git a/scripts/integration-tests/e2e-babel.sh b/scripts/integration-tests/e2e-babel.sh index 995bcad41a45..e21d3b4063a1 100755 --- a/scripts/integration-tests/e2e-babel.sh +++ b/scripts/integration-tests/e2e-babel.sh @@ -33,6 +33,10 @@ startLocalRegistry "$PWD"/scripts/integration-tests/verdaccio-config.yml node "$PWD"/scripts/integration-tests/utils/bump-babel-dependencies.js # Build and test -YARN_ENABLE_IMMUTABLE_INSTALLS=false make -j test-ci +YARN_ENABLE_IMMUTABLE_INSTALLS=false make -j build-standalone-ci +for i in {1..50}; do + echo "RUN NUMBER $i" + BABEL_ENV=test yarn jest --maxWorkers=4 --ci +done cleanup