Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jest-worker and typescript unexpected behavior #8872

Closed
tedconn opened this issue Aug 23, 2019 · 8 comments
Closed

jest-worker and typescript unexpected behavior #8872

tedconn opened this issue Aug 23, 2019 · 8 comments

Comments

@tedconn
Copy link

tedconn commented Aug 23, 2019

🐛 Bug Report

Jest tests fail with this error:

Call retries were exceeded

      at ChildProcessWorker.initialize (node_modules/jest-worker/build/workers/ChildProcessWorker.js:193:21)

...

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

To Reproduce

Using jest and @babel/preset-typescript, and jest-worker, create a test which creates a new jest-worker which invokes a typescript definition.

Expected behavior

The typescript worker is run without error and the result returned to the test

Link to repl or repo (highly encouraged)

Repro is here:
https://github.com/tedconn/worker-jest-ts

I was actually trying to repro a different issue but when trying to come up with a repro I would have expected this simple case to work!

envinfo

System:
    OS: macOS 10.14.6
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  Binaries:
    Node: 12.9.0 - ~/.nvm/versions/node/v12.9.0/bin/node
    Yarn: 1.13.0 - /usr/local/bin/yarn
    npm: 6.10.2 - ~/.nvm/versions/node/v12.9.0/bin/npm
  npmPackages:
    jest: ^24.9.0 => 24.9.0 
@SimenB
Copy link
Member

SimenB commented Aug 24, 2019

Could you add a readme to the reproduction with which commands to run in order to reproduce the bug, and describe what behaviour you expected?

@tedconn
Copy link
Author

tedconn commented Aug 25, 2019

@SimenB
Copy link
Member

SimenB commented Aug 26, 2019

Thanks for the small reproduction!

The underlying cause of the error here is that jest-worker does not transpile the module passed to it. So you need to either transpile beforehand or use something like pirates.

The bad error message is because jest-worker by default passes silent: true when forking: https://github.com/facebook/jest/blob/8c169d20add61c8831162d8347d2710c07b6b0ef/packages/jest-worker/src/workers/ChildProcessWorker.ts#L93 & https://github.com/facebook/jest/blob/8c169d20add61c8831162d8347d2710c07b6b0ef/packages/jest-worker/src/workers/NodeThreadsWorker.ts#L74.
Jest itself then pipes stdout and stderr manually in the parent: https://github.com/facebook/jest/blob/8c169d20add61c8831162d8347d2710c07b6b0ef/packages/jest-runner/src/index.ts#L138-L139

To see the syntax error, either pass forkOptions: { silent: false } when instantiating the Worker, or do the same pipe thing that jest does.

Doing either of those will bubble up the syntax error:

image


We can probably improve our docs here. Ideas on how we could have made this clearer in the readme?

/cc @thymikee @jeysal

@thymikee
Copy link
Collaborator

A note in the docs & readme should be just enough. @tedconn would you like to contribute it?

@tedconn
Copy link
Author

tedconn commented Aug 28, 2019

Thanks for the follow up.

I can contribute that.

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Feb 25, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 27, 2023
@github-actions
Copy link

This issue 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 Apr 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants