Skip to content

Commit

Permalink
Add debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed May 16, 2022
1 parent 97cc436 commit ce563b8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
33 changes: 20 additions & 13 deletions eslint/babel-eslint-parser/src/client.cjs
Expand Up @@ -64,26 +64,33 @@ exports.WorkerClient = class WorkerClient extends Client {

constructor() {
super((action, payload) => {
const wt = WorkerClient.#worker_threads;

this.#signal[0] = 0;
const subChannel = new WorkerClient.#worker_threads.MessageChannel();
const subChannel = new wt.MessageChannel();

this.#worker.postMessage(
{ signal: this.#signal, port: subChannel.port1, action, payload },
[subChannel.port1],
);

Atomics.wait(this.#signal, 0, 0);

let resp;
for (let i = 0; i < 100; i++) {
resp = WorkerClient.#worker_threads.receiveMessageOnPort(
subChannel.port2,
);
if (resp) break;
Atomics.wait(this.#signal, 1, 0, 5);
}

const message = resp.message;
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 ? Infinity : 5);
response = wt.receiveMessageOnPort(subChannel.port2);

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;
});
Expand Down
6 changes: 5 additions & 1 deletion scripts/integration-tests/e2e-babel.sh
Expand Up @@ -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

0 comments on commit ce563b8

Please sign in to comment.