From 33ad7c6d6f8ad4293316bab7b21bbc639fb61970 Mon Sep 17 00:00:00 2001 From: Igor Strebezhev Date: Sun, 7 Mar 2021 15:20:05 +0300 Subject: [PATCH] Fix unhandled ERR_IPC_CHANNEL_CLOSED and a deadlock (#11144) --- CHANGELOG.md | 1 + packages/jest-worker/src/workers/ChildProcessWorker.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3d034ce2a98..fa14e7fc7794 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ - `[jest-transform]` [**BREAKING**] Refactor API of transformers to pass an options bag rather than separate `config` and other options ([#10834](https://github.com/facebook/jest/pull/10834)) - `[jest-worker]` [**BREAKING**] Use named exports ([#10623](https://github.com/facebook/jest/pull/10623)) - `[jest-worker]` Do not swallow errors during serialization ([#10984](https://github.com/facebook/jest/pull/10984)) +- `[jest-worker]` Handle `ERR_IPC_CHANNEL_CLOSED` errors properly ([#11143](https://github.com/facebook/jest/pull/11143)) - `[pretty-format]` [**BREAKING**] Convert to ES Modules ([#10515](https://github.com/facebook/jest/pull/10515)) - `[pretty-format]` Only call `hasAttribute` if it's a function ([#11000](https://github.com/facebook/jest/pull/11000)) diff --git a/packages/jest-worker/src/workers/ChildProcessWorker.ts b/packages/jest-worker/src/workers/ChildProcessWorker.ts index 6b7daa4758f2..ba47862cadfe 100644 --- a/packages/jest-worker/src/workers/ChildProcessWorker.ts +++ b/packages/jest-worker/src/workers/ChildProcessWorker.ts @@ -202,9 +202,10 @@ export default class ChildProcessWorker implements WorkerInterface { } } - private _onExit(exitCode: number) { + private _onExit(exitCode: number | null) { if ( exitCode !== 0 && + exitCode !== null && exitCode !== SIGTERM_EXIT_CODE && exitCode !== SIGKILL_EXIT_CODE ) { @@ -236,7 +237,7 @@ export default class ChildProcessWorker implements WorkerInterface { this._request = request; this._retries = 0; - this._child.send(request); + this._child.send(request, () => {}); } waitForExit(): Promise {