-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Cannot find module, because of infinite loop in jest-resolver #5088
Comments
Would love a PR fixing
Hopefully not. You can take a look at node's resolution to see if there are any holes? https://github.com/nodejs/node/blob/604578f47ea360980110e2cd7d4a636f9942b1f0/lib/module.js#L151-L153 |
Thanks @SimenB, we will send a PR soon! |
Looks like modules with a main entry of "./" (like co-request) are also susceptible to this issue. I'll open a separate issue for this. |
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. |
After experiencing a lot of intermittent errors like this one:
I looked at the resolver code and realized there was an infinite loop that would eventually cause this error to appear. We have a couple of NPM modules that in their package.json file have the main entry point defined as:
Because of this, the following line of code would make a path resolve into the same path.
https://github.com/facebook/jest/blob/78477eb526f2ebd901f3daa0abef0e8cc591bfb8/packages/jest-resolve/src/default_resolver.js#L133
This will call the
tryResolve
function with the same path, that will go on and on until the maximum call stack is reached. I tried changingpkgmain
to "index.js" whenever it was defined as "." and the issue went away.Wondering if there could be other differences in how Node resolution of modules works vs. how the Jest resolver works. Let me know if my team can contribute to fix this. Looking forward to help.
The text was updated successfully, but these errors were encountered: