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: improve error on module not found #8704

Merged
merged 2 commits into from
Sep 10, 2022

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Jul 17, 2019

Summary

Before
image

After
image

Test plan

E2E test added

@@ -52,6 +52,9 @@ class NodeEnvironment implements JestEnvironment {
global.TextDecoder = TextDecoder;
}
installCommonGlobals(global, config.globals);
// Node's error-message stack size is limited at 10, but it's pretty useful
Copy link
Member Author

Choose a reason for hiding this comment

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

to match jsdom env

@@ -84,6 +84,9 @@ async function runTestInternal(
resolver: Resolver,
context?: TestRunnerContext,
): Promise<RunTestInternalResult> {
// Node's error-message stack size is limited at 10, but it's pretty useful
// to see more than that when a test fails.
Error.stackTraceLimit = 100;
Copy link
Member Author

Choose a reason for hiding this comment

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

when the error happens outside the test sandbox (such as when resolving a dependency in jest-runtime)


at Resolver.resolveModule (../../packages/jest-resolve/build/index.js:259:17)
at Object.<anonymous> (node_modules/discord.js/src/index.js:21:12)
at Object.require (test.js:3:1)
Copy link
Member Author

Choose a reason for hiding this comment

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

this line is about 15 lines into the stack, which is why it wasn't included before (and we were missing the code frame)

Copy link
Collaborator

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

Add a changelog? :D

@SimenB SimenB force-pushed the improve-stack-when-mdule-not-found branch from 6d986a6 to 9b4cbac Compare July 17, 2019 12:28
@SimenB
Copy link
Member Author

SimenB commented Jul 17, 2019

I have no idea why there's more open handles with this change :(

@thymikee
Copy link
Collaborator

Maybe Error is not cleaned up after we touch it?

@SimenB
Copy link
Member Author

SimenB commented Jul 17, 2019

I wonder if the change to stack limit means old frames aren't gc-ed. Can we change the length and trigger a gc before checking for handles? maybe...

@SimenB SimenB force-pushed the improve-stack-when-mdule-not-found branch 2 times, most recently from 29a90d2 to dae11e5 Compare July 17, 2019 15:50
@SimenB SimenB force-pushed the improve-stack-when-mdule-not-found branch 2 times, most recently from 6a4f9c3 to 70f9077 Compare September 6, 2019 15:44
@SimenB SimenB force-pushed the improve-stack-when-mdule-not-found branch 2 times, most recently from 1d5b8c0 to e5d4d10 Compare November 9, 2019 17:00
@SimenB SimenB force-pushed the improve-stack-when-mdule-not-found branch 2 times, most recently from edb669d to 6b1d2ba Compare April 28, 2020 20:01
@SimenB SimenB force-pushed the improve-stack-when-mdule-not-found branch 2 times, most recently from 83ad129 to e81cfaf Compare May 3, 2020 18:16
@SimenB SimenB force-pushed the improve-stack-when-mdule-not-found branch from e81cfaf to f1dc432 Compare August 6, 2020 12:18
@SimenB SimenB force-pushed the improve-stack-when-mdule-not-found branch from f1dc432 to 3d1d24a Compare August 23, 2020 21:15
@github-actions
Copy link

github-actions bot commented Sep 8, 2022

This PR is stale because it has been open 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 Sep 8, 2022
@SimenB SimenB force-pushed the improve-stack-when-mdule-not-found branch from 3d1d24a to 2a1a8ba Compare September 9, 2022 07:35
@github-actions github-actions bot removed the Stale label Sep 9, 2022
@SimenB SimenB merged commit cbf0992 into jestjs:main Sep 10, 2022
@SimenB SimenB deleted the improve-stack-when-mdule-not-found branch September 10, 2022 14:34
@SimenB
Copy link
Member Author

SimenB commented Sep 10, 2022

Oldie! 😀

@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 Oct 11, 2022
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