-
-
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
Clear resolved modules cache before runJest in watch mode #8650
Clear resolved modules cache before runJest in watch mode #8650
Conversation
debd2a8
to
1aabd98
Compare
It seems like a good place to clear it, yeah. Do you have a repro for a bug with this so that we can check that it is fixed? |
I did not see a special issue. I have only comment with this bug after merge my previus PR. |
Ah okay, thanks a lot for following up to ensure quality here! :) Go ahead then, would be cool to have a test that simulates a change in what a file resolves to in order to test the cache invalidation, I don't think we have something like this yet 😅 |
2f5380a
to
f404fbd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for following up @Connormiha!
I left a comment on how I imagine the test could be more realistic, do you think that could work? The test is still fine if it doesn't work out, this is just something I thought about writing the last comment that would be a cool way of testing this cache invalidation.
packages/jest-resolve/src/index.ts
Outdated
@@ -79,6 +79,10 @@ class Resolver { | |||
this._modulePathCache = new Map(); | |||
} | |||
|
|||
static clearCache() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this only clears the cache of the default resolver, should the name change to reflect that?
Potentially, add the property to the resolver itself, and check of resolver.clearCache
or something exists?
f404fbd
to
5192931
Compare
@jeysal i added real test. |
5192931
to
461b527
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Connormiha This is absolutely amazing, thanks for all the effort you put into it. Testing watch mode reruns with so little is very impressive and I think the test could be a very good example for similar things in the future.
Any clue what might cause the test to fail on Windows? Probably fs-related but I can't find anything problematic in the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing. The jest-circus failure happens on master as well, no need to worry about that I think. Just commented on one more thing I found when checking this out locally.
f11847a
to
1d93984
Compare
1d93984
to
b5f09eb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. We could add Resolver.clearCache
to the resolver API, so that custom ones can benefit this behavior as well, if the method is present. I'm fine doing that in the followup
}, | ||
); | ||
|
||
const config = normalize( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason not to use createGlobalConfig
and createProjectConfig
from TestUtils.ts
in root here? Instead of normalize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makeGlobalConfig
from TestUtils.ts
doesn't use normalizer inside. Without it this test will not work correct.
watchman: false, | ||
}); | ||
|
||
const realContext = await hasteMapInstance.build().then(hasteMap => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 await
s instead of the then
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need both variables hasteMapInstance
and realContext
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const hasteMap = await hasteMapInstance.build();
const realContext = {
config,
hasteFS: hasteMap.hasteFS,
moduleMap: hasteMap.moduleMap,
resolver: Runtime.createResolver(config, hasteMap.moduleMap),
};
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasteMapInstance should be passed in watch. Build doens't return instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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. |
Summary
This patch fixes bug with
watchAll
mode.#8388 (comment)
My solution:
I just clear
checkedPaths
before repeated run in watch mode to avoid situation when we have legacy path information.Test plan
I added test to avoid this bug in a future.