Skip to content

fix(worker): do not swallow errors when sending custom messages#10984

Merged
SimenB merged 1 commit intojestjs:masterfrom
SimenB:worker-message-parent-error
Dec 28, 2020
Merged

fix(worker): do not swallow errors when sending custom messages#10984
SimenB merged 1 commit intojestjs:masterfrom
SimenB:worker-message-parent-error

Conversation

@SimenB
Copy link
Copy Markdown
Member

@SimenB SimenB commented Dec 28, 2020

Summary

Extracted from #10981.

Test plan

Error from the reproduction of #10577 changes from

  ● Test suite failed to run

    "messageParent" can only be used inside a worker

      at messageParent (packages/jest-worker/build/workers/messageParent.js:46:11)

to

  ● Test suite failed to run

    TypeError: Converting circular structure to JSON
        --> starting at object with constructor 'Object'
        --- property 'ref' closes the circle
        at stringify (<anonymous>)

      at messageParent (packages/jest-worker/build/workers/messageParent.js:42:19)

When using jest-circus which makes use of this function

import {PARENT_MESSAGE_CUSTOM} from '../types';

const isWorkerThread = () => {
const isWorkerThread: boolean = (() => {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only run this once instead of on each invocation of the messageParent function

})();

const messageParent = (
export default function messageParent(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should ignore whitespace here - diff is removed try-catch and added type information

https://github.com/facebook/jest/pull/10984/files?w=1

@SimenB SimenB merged commit 0c75d62 into jestjs:master Dec 28, 2020
@SimenB SimenB deleted the worker-message-parent-error branch December 28, 2020 15:21
@github-actions
Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants