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

fix: add console error to catch block #6665

Closed
wants to merge 2 commits into from

Conversation

J-Dickson
Copy link

Summary

I had an issue recently where the jest-resolve-dependencies was swallowing errors in the catch statement. The error was actually causing the jest --watch command to hang, I thought that it'd be helpful for users to see the errors so that they are able to rectify them.

I found that errors were being swallowed from the following: #6025

Test plan

No tests added for a console.error

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@codecov-io
Copy link

codecov-io commented Jul 10, 2018

Codecov Report

Merging #6665 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6665      +/-   ##
==========================================
+ Coverage   63.73%   63.74%   +<.01%     
==========================================
  Files         235      235              
  Lines        8940     8941       +1     
  Branches        4        3       -1     
==========================================
+ Hits         5698     5699       +1     
  Misses       3241     3241              
  Partials        1        1
Impacted Files Coverage Δ
packages/jest-resolve-dependencies/src/index.js 97.67% <ø> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e930c70...2c07aa7. Read the comment docs.

@@ -47,7 +47,9 @@ class DependencyResolver {
}
try {
return this._resolver.resolveModule(file, dependency, options);
} catch (e) {}
} catch (e) {
console.error(e);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure why we fallback to mock module here... I think a better approach would be to just rethrow the error unless we want to fetch the mock.

@SimenB
Copy link
Member

SimenB commented Jul 10, 2018

This is pretty old code (from #1007)

@cpojer why would we want to swallow that error?


@J-Dickson Could you add a test which shows how this error was previously swallowed? An integration test asserting on stderr and/or stdout would be nice

@thymikee
Copy link
Collaborator

IIRC the error is swallowed, because we handle it somewhat later (e.g. file doesn't exists on FS because it's a mock). Try to checkout this PR locally and see what happens when you run yarn jest --watch or yarn jest packages --watch: it will spawn a lot of "MODULE_NOT_FOUND" errors, that

@J-Dickson
Copy link
Author

Yup, but there are scenarios in which this causes the --watch to hang with no user output, making it pretty much impossible for a user to figure out what the issue is.

@SimenB yeah, no worries. I will write one when I get a little bit of free time. The issue I had was basically imports with paths that could not be found.

@thymikee
Copy link
Collaborator

@J-Dickson have you tried with this patch? #6407
It's already on master

@J-Dickson
Copy link
Author

Sorry for the late response, seems like that should work, yeah! Thanks, will close the PR.

@J-Dickson J-Dickson closed this Jul 18, 2018
@SimenB
Copy link
Member

SimenB commented Jul 18, 2018

Available in 23.4.0

@github-actions
Copy link

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 12, 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.

5 participants