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
Filesystem Cache is throwing TypeError: Cannot read property 'length' of undefined from ResolverCachePlugin #11668
Comments
hm, maybe you can create reproducible test repo? |
Right now I am just crawling through the repo that works and the repo that doesn't to try and find any differences. I am baffled - although I am wondering if this is some sort of strange permissions issue since the working repo is quote old (2-3 years) and the problem repo was created in the last month or so. |
Same computer, same webpack config, different folders. |
@gtwilliams03 Perhaps we are not processing a specific case, perhaps the configuration would be enough to understand it |
Here is the output of my webpack config:
|
Do you have the error when you run dev server or just simple build? Can you try to remove |
I get the error when I run a build or dev server. |
I also get the error with or without the |
I'm afraid we still have to look at reproducible test repo to fix it, hard to say why it is broken 😞 |
I was getting the same error in my project. |
@gtwilliams03 maybe you can provide more stack? |
@egs33 Can you create minimum reproducible test repo? |
@evilebottnawi I made a repository to reproduce. https://github.com/egs33/webpack5-cache-error |
@egs33 big thanks, found the problem |
@egs33 Thank you so much! I was trying to figure out how to break the project apart to come up with a reproducible repo... Much appreciated! |
@gtwilliams03 anyway try to disable cache and look on your error, you need to fix it |
@evilebottnawi I don't get any errors when I set |
Yes |
In my OP, I don't get any errors with |
@gtwilliams03 this problem happens only when you have resolving errors |
Sorry for asking a dumb question, but how do I see the resolving errors when they don't show up in the terminal? I was actually just looking at the ResolverCachePlugin code and seeing if I could log some details in there... |
@gtwilliams03 it should be shown in |
It seems to be failing before the |
@gtwilliams03 maybe do you can create reproducible repo too? I want to investigate, maybe we have two different errors 😄 |
I am still trying to figure out what module isn't resolving. The webpack-cli is dying before I can get meaningful output.
|
I wonder why webpack-cli suppresses the stack trace... |
Somehow there is an
I changed this line to:
and it works fine. No idea what path I have in my project that is creating the undefined value. Submitted a pull request to |
There shouldn't be a undefined value there. Seems like something is passing |
If this is a resolving problem - could someone please elaborate or post a link on how to debug and find the eventual culprit? I have a fully working build, no errors or warnings (unless I enable filesystem cache with path to config that is..), no runtime errors, but still can't enable file system cache due to this issue. |
@joakimriedel interesting, can you provide reproducible test repo? |
@evilebottnawi I'll try my best, it's a pretty big project evolved during many years and versions of Webpack so I'll need to break it down a bit first. During the last hour, I got at least the following findings; At this line: https://github.com/webpack/enhanced-resolve/blob/0f51a8cf62b47cde4f57977cf4a205d832f8da69/lib/ParsePlugin.js#L33 the {"_ResolverCachePluginCacheMiss":true,"context":{},"path":"C:/Users/<redacted>/wwwroot/src/css"} This lead me to put a debug log at this line: https://github.com/webpack/enhanced-resolve/blob/0f51a8cf62b47cde4f57977cf4a205d832f8da69/lib/Resolver.js#L398 if (/\/src\/css$/.test(request.path)) {
console.log(JSON.stringify(hook));
console.log(JSON.stringify(request));
console.log(JSON.stringify(message));
} Which lets me see earlier in the process that the mysterious path comes from resolving /* bootstrap scss bundle */
@import "~bootstrap/scss/bootstrap"; using the following loader configuration {
test: /\.scss$/,
use: [
{
loader: "style-loader", // injects css into DOM
},
{
loader: "css-loader",
options: { sourceMap: !env.production, importLoaders: 1 },
},
{
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [
[
"postcss-preset-env",
{
// Options
},
],
],
},
sourceMap: !env.production,
},
},
{
loader: "sass-loader",
options: {
sourceMap: !env.production,
sassOptions: {
outputStyle: "expanded", // keeps comments, such as autoprefixer commands, in output css file
},
},
},
],
}, I suspect some combination of Bootstrap and Webpack and sass-loader is involved. I will need further time to generate a repo, but perhaps others like @johnthecat or @gtwilliams03 can confirm if they also use Bootstrap in their configuration? |
I'm seeing similar issues, and also have a .scss file containing:
|
Thanks I will look at this in near future, a lot of issues 😞 |
Hmm, it looks like there is no error in webpack, problem with |
@jdelStrother @joakimriedel Yes - my project also contains |
I'm sorry for the bootstrap red herring. It turned out to be fontawesome. I have a repro here: https://github.com/joakimriedel/webpack-cache-bug-repro Building this repro will show error. Remove cache from config - no error - builds just fine. |
Yes, I found bug, two problems:
const resolve = loaderContext.getResolve(options);
resolve(context, undefined);
// or resolve(undefined, undefined) WIP on first I even can tell you why there is an error with |
This comment has been minimized.
This comment has been minimized.
@evilebottnawi can confirm sass-loader 10.0.4 solves the issue I've had with the cache, webpack 5 feels rock solid now! 🎉 In my real project, compile time went from 14440 ms to 1667 ms using the filesystem cache. (on a threadripper/nvme m.2) I'm really curious about the small change to bring the compile time even further down? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Is this issue fixed for |
@drewlustro Yes (webpack/enhanced-resolve#261), but you will have error in this case, so we need to find loader with problems, can you provide config/minimum reproducible test repo |
Fixed in both places (update deps to latest, i.e. |
@joakimriedel Can you try https://github.com/webpack-contrib/terser-webpack-plugin/releases/tag/v5.0.1 and provde some feedback on performance? Try it on |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I JUST UPGRADE WEBPACK in my PROJECT and works fine! |
This issue happened for me when path is lower case "c:" This can be seen by putting a conditional breakpoint in the paths.map function in the method "apply(resolver)" inside "ehanced-resolve/lib/ModulesInHierarchicalDirectriesPlugin.js" |
Bug report
What is the current behavior?
Attempting to get the cache working for webpack 5. I have it working on one of my local repos, but this one (a clone of a different website), is throwing an error:
Relevant config:
Throws this error:
Setting the webpack config
config: false
eliminates the error and the build runs normally.If the current behavior is a bug, please provide the steps to reproduce.
I see directories being created under my working repo in the
node_modules/.cache
folder, but not on my problem repo. A.cache
folder is created, but nowebpack
orwebpack/client-development
folders.What is the expected behavior?
Cannot figure out why one repo is throwing this error and the other is not.
Other relevant information:
webpack version: 5.0.0
Node.js version: 14.13.1
Operating System: MacOS Catalina 10.15.7
Additional tools:
The text was updated successfully, but these errors were encountered: