Skip to content

Commit

Permalink
Fallback to plain console log of whole structure when messageParent()…
Browse files Browse the repository at this point in the history
… fails due to bigint json serialisation
  • Loading branch information
klesun committed Jun 28, 2021
1 parent b5fe373 commit 31bed58
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion build/workers/messageParent.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ function messageParent(message, parentProcess = process) {

parentPort.postMessage([_types().PARENT_MESSAGE_CUSTOM, message]);
} else if (typeof parentProcess.send === 'function') {
parentProcess.send([_types().PARENT_MESSAGE_CUSTOM, message]);
try {
parentProcess.send([_types().PARENT_MESSAGE_CUSTOM, message]);
} catch (error) {
console.error('jest-worker message serialization failed', error);
console.dir(message, {depth: 10});
throw error;
}
} else {
throw new Error('"messageParent" can only be used inside a worker');
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jest-worker",
"version": "27.0.2",
"version": "27.0.2-bigintfix",
"repository": {
"type": "git",
"url": "https://github.com/facebook/jest.git",
Expand Down Expand Up @@ -36,4 +36,4 @@
,"_resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.0.2.tgz"
,"_integrity": "sha512-EoBdilOTTyOgmHXtw/cPc+ZrCA0KJMrkXzkrPGNwLmnvvlN1nj7MPrxpT7m+otSv2e1TLaVffzDnE/LB14zJMg=="
,"_from": "[email protected]"
}
}

0 comments on commit 31bed58

Please sign in to comment.