Closed JonWallsten closed 4 years ago
Something wrong with loader, it is not problem with webpack-cli, please provide reproducible test repo
@evilebottnawi : I see, then it's probably something wrong with Angular's tooling I use @ngtools/webpack
and I saw some references to an Angular module while debugging. Not sure where to begin though. Care to explain why it's set to false and why false should not be handled by the code? So I can explain in the bug report to Angular? Thanks!
Care to explain why it's set to false and why false should not be handled by the code?
Because false
means nothing was found, and other plugins can do additional search
So I can explain in the bug report to Angular?
Yes
If you provide reproducible test repo I can search where it happens
If you provide reproducible test repo I can search where it happens
Sure. Give me a few hours to set it up. Thanks!
@evilebottnawi: I've created a repo now by removing most of our code but leaving the structure. One thing that differ though is that in my repro the web-lib-core library is completely missing __webpack_require__
for some reason. That is not happening in our app right now. So to get to the real problem I need help with understandning why this is happening.
Close this repo:
https://github.com/JonWallsten/monorepo-new/tree/angular%2Bwebpack-upgrade
I sent you an invite since it's private. Create an issue with any questions about installing/running. I'll answer as fast as I can.
Thanks, I will look at this in near future, sorry a lot of issue after webpack@5, we are working on it
Thanks, I will look at this in near future, sorry a lot of issue after webpack@5, we are working on it
No stress! I'm just trying to stay ahead. We don't have to upgrade any time soon.
@JonWallsten How I can reproduce it? I have only warnings and deprecation messages and couple of problems with invalid export, but no problem as you described above
@evilebottnawi I'm unable to reproduce it in the stripped repo. Can only do it in our real repo. Will try do add some more stuff to the repro so we can reproduce it.
@evilebottnawi: I'm having a hard time creating this repro bacause I can't get past the __webpack_require__ is not defined
error, and I don't get why it can't. It works in our main repo and it works fine in Webpack 4. Aslo the code looks fine. But I might net get eval completely. Take a look at this:
It passes __webpack_require__ to the function calling eval.
When looking at it with DevTools you can see that it's defined. So why is it missing when calling eval? Isn't that using the current scope?
Here's the scope:
Edit: I got past the error by using inline-source-map instead. Will try to recreate the actual error now.
__webpack_require__ is not defined
Can't help without reproducible test repo
@evilebottnawi: In the branch where it fails result is defined as this:
I have tried to import stuff from Material dialog in the repro-branch to force this, but it never has a result with that file. I don't have enough knowledge about ResolverCachePlugin to understand what has to happen for a file to end up in this process. Do you mind helping me out, please?
Sorry I can't help, if you provide more stack trace maybe I can, if you create reproducible test repo we will fix it today, we already lost many time...
Do you use boilerplaces? What is versions? Do you try latest version? Which plugin you use, because some of them still have problems with webpack@5
Do you use boilerplaces? What is versions? Do you try latest version? Which plugin you use, because some of them still have problems with webpack@5
The only thing I can come up with is that @ngtools/webpack is not supporting Webpack@5. Let's close this until everything is updated and I'll create a new bug if it's still a problem. I should not take up any more of your time,
The only thing I can come up with is that @ngtools/webpack is not supporting Webpack@5.
Yep :disappointed: But I saw a similar problem and I saw it was fixed, maybe ngtools has branch with webpack@5 and you can test it?
I thought they already did support it. That's why I tested. But according to the package. json in master they don't yet. So it will probably be fixed once they decide to update.
Feel free to feedback
I'm working with @ngtools/webpack
's AngularCompilerPlugin
, Webpack 5 and facing the same exception as @JonWallsten when using webpack-dev-server
.
If I replace
if (callbacks === undefined)
through
if (!callbacks)
in node_modules\webpack\lib\cache\ResolverCachePlugin.js
(on line 213) everything works like a charm.
So, for me the question is why the variable callbacks
can be false
and why it's only tested for undefined
and not false
before iterating over it...
@loebi-ch the problem in AngularCompilerPlugin
, it should be fixed in next/alpha/beta versions
I'm still trying to recreate it so the Angular team can fix it. But I still haven't been able to. Since I don't know what's causing the value to be false
and can't force the issue in my repro.
In my not working repo it looks like this:
So the obvious thing here is that it's trying to cache the same file multiple times. I have added imports from the same file in my repro and it still works, so it's not that easy.
Seems to be the same issuer trying to cache the file:
File is cached: ./__ivy_ngcc__/fesm2015/dialog.js
--issuer: C:\Users\user\repo\oas-web\packages\web-app-edit\src\app\app.module.ts
CALLBACK IS FALSE: ./__ivy_ngcc__/fesm2015/dialog.js
--issuer: C:\Users\user\repo\oas-web\packages\web-app-edit\src\app\app.module.ts
@evilebottnawi: Do you have any idea that the loader is doing wrong? Not waiting for the file to be cached? Not retrieving the cached file?
@JonWallsten I don't sure it is webpack cache
But the issue is that something is calling done
multiple times for the same file, right?
After first time callback
is set to false
. Next time done
is called it fails because callback
is false
.
const done = (err, result) => {
if(result && result.relativePath.indexOf('fesm2015') !== -1) {
console.log('File is cached: ', result.relativePath);
console.log('--issuer: ', result.context.issuer);
}
if(callbacks === false) {
console.log('CALLBACK IS FALSE: ', result.relativePath);
console.log('--issuer: ', result.context.issuer);
return;
}
if (callbacks === undefined) {
callback(err, result);
callbacks = false;
} else {
for (const callback of callbacks) {
callback(err, result);
}
activeRequests.delete(identifier);
callbacks = false;
}
};
It seems to be fine as long as issuer is not the same.
File is cached: ./__ivy_ngcc__/fesm2015/dialog.js
--issuer: C:\Users\user\repo\monorepo-new\packages\web-app-edit\src\app\app.component.ts
File is cached: ./__ivy_ngcc__/fesm2015/dialog.js
--issuer: C:\Users\user\repo\monorepo-new\packages\web-app-edit\src\app\components\start\start.component.ts
File is cached: ./__ivy_ngcc__/fesm2015/dialog.js
--issuer: C:\Users\user\repo\monorepo-new\packages\web-app-edit\src\app\shared-services\test.service.ts
Please ignore that it says "File is cached". I have no idea how the ResolverCachePlugin works and why or how it ends up in the done
function.
Edit: What is _ResolverCachePluginCacheMiss? It's set to true
when callback
is set to false
I say, it was bug on AngularCompilerPlugin, it was fixed a long time ago, if you need help and investigation - please create reproducible test repo, I can't work with text, too little context, too little understanding, and too much code, it's really hard and not effective
The issue is that I can't create a repro. I've been trying for a week. It only seems to happen when you import stuff is a specific way. I've really been trying to force it. I'm using the latest release from Angular, released yesterday. So I don't think it's fixed. The issue occur in our repo every single build.
@evilebottnawi If this is a bug in AngularCompilerPlugin
, it was not fixed a long time ago. I use the latest releases of Angular (11.0.0) and @ngtools/webpack
(11.0.0) both released yesterday evening and this bug still occurs.
And even if this is a bug in AngularCompilerPlugin
, the error is thrown in in ResolverCachePlugin
and could be easily solved by checking callbacks
before iterating over it... As I wrote earlier, I fixed the bug by just replacing line 213 and everything works as expected.
@loebi-ch: I think his point is that the source of the issue is not fixed by patching up ResolveCachePlugin. However it would still be nice to at least throw an error if callbacks
is false
with a description of the error, and why it occurs. Since you can end up there with the value false
is hould at least be handled and not throw an uncaught error. I still don't know that the actual issue is...
Someone in the Angular team just said they are investigating the issue and that you should add cache: false
in your Webpack config for now.
@JonWallsten Thank you for your efforts. I've already seen your answers in https://github.com/angular/angular-cli/issues/19351.
I know that it needs some deeper investigations to find the root cause of the problem, but as you just have written, it would be nice to handle the uncaught error in ResolveCachePlugin
.
@loebi-ch: Yeah, whatever's the issue it should not just be unhandled if it can happen this frequently.
I know that it needs some deeper investigations to find the root cause of the problem, but as you just have written, it would be nice to handle the uncaught error in ResolveCachePlugin.
It is invalid fix and will break resolving cache for other places
If you need fast fix, please try to create reproducible test repo, I can't fix something somewhere, sorry
We don't need a quick fix. We're just trying to get to the bottom of this. If it was fixed 29 days ago it would definitely be in the release yesterday. And since it's still an issue obviously it's not fixed. The Angular team is also trying to investigate this: https://github.com/angular/angular-cli/issues/19351
I'll let you know if I find anything else. And like a said many times over, I've am trying to create a minimal repo. It's just really hard.
@JonWallsten Maybe you can provide private access to your repo and steps to reproduce, I can sign NDA if you need this
@evilebottnawi: They thing is we host or own Github-server and you need access to our internal network to access server's needed to start the application. Maybe sharing screen or something would work worst case.
I am afraid that screenshots will not be enough, I need to look on context/request/etc in resolver
I meant sharing my screen live, not just screeshots!
@evilebottnawi: It's a classic race condition! The same issuer is trying to resolve the file twice in a very short time but since the resolver is async the second one is triggered before the first one in done, but after the first one is triggered. After the first request is done it sets callbacks
to false
so when the second request is done it tries to iterate false
.
I've stepped through the code with a delay for each file and the problem goes away,
The issuer, app.module.ts
, has no direct import of the file that fails, so it might be because how Angular imports other modules. If the source of the issue was another file in the current app, the issuer should be that file and not app.module.ts
.
Is it possible to get more information about the source then this?
{
cacheable: true
context: "C:\Users\<user>\repo\oas-web\packages\web-app-edit\src\app"
contextDependencies: LazySet {_set: Set(0), _toMerge: Set(0), _toDeepMerge: Array(0), _needMerge: false, _deopt: false}
contextInfo:
compiler: undefined
issuer: "C:\Users\<user>\repo\oas-web\packages\web-app-edit\src\app\app.module.ts"
__proto__: Object
createData: {}
dependencies: Array(1)
0: CommonJsRequireDependency
loc: SourceLocation {start: Position, end: Position}
optional: false
range: (2) [10671, 10697]
request: "@angular/material/dialog"
userRequest: "@angular/material/dialog"
weak: false
category: (...)
disconnect: (...)
module: (...)
type: (...)
__proto__: ModuleDependency
length: 1
__proto__: Array(0)
fileDependencies: LazySet {_set: Set(0), _toMerge: Set(0), _toDeepMerge: Array(0), _needMerge: false, _deopt: false}
missingDependencies: LazySet {_set: Set(0), _toMerge: Set(0), _toDeepMerge: Array(0), _needMerge: false, _deopt: false}
request: "@angular/material/dialog"
resolveOptions:
__proto__: Object
__proto__:
}
LIke a said in my previous posts the file mentioned app.module.ts
does NOT import @angular/material/dialog
, directly, so Angular probably parses the file somehow and does this. But I can't find any details about this. So it's hard to fine the source of the issue.
I don't know how I can help you here...
@evilebottnawi: It's a classic race condition! The same issuer is trying to resolve the file twice in a very short time but since the resolver is async the second one is triggered before the first one in done, but after the first one is triggered. After the first request is done it sets callbacks to false so when the second request is done it tries to iterate false.
Sounds like the bug on angular side.
Maybe you can remove pieces of code by reproducing the problem every time and show it (example of repo). There can be many places with problems here, I still can't say anything, sorry
Yeah, I'll wait and see what they say! I'll get back to you as soon as I have any other info. Thanks!
@evilebottnawi I've successfully made a repro now! Use the branch below. I have stripped away almost the full monorepo and only kept one app, that I placed at the root level. I removed most of the Angular stuff as well. It's just two components left. https://github.com/JonWallsten/monorepo-new/tree/webpack-5-issue Simple instructions in the Readme in that branch. Let me know if you need anything.
@JonWallsten hm, I don't have callback is not iterable
here, only: ERROR Error: Uncaught (in promise): RangeError: Maximum call stack size exceeded
Tried many times
@JonWallsten hm, I don't have
callback is not iterable
here, only:ERROR Error: Uncaught (in promise): RangeError: Maximum call stack size exceeded
That's weird. I did not get that. Let me try to install everything from the beginning and clean up and see if I can get that.
@evilebottnawi: Works fine for me! Node version issue?
~\..\monorepo-new webpack-5-issue npm i
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
> @angular/cli@11.0.0 postinstall C:\Users\me\repo\monorepo-new\node_modules\@angular\cli
> node ./bin/postinstall/script.js
> web-app-edit@0.0.0-PLACEHOLDER postinstall C:\Users\me\repo\monorepo-new
> ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points
Compiling @angular/core : es2015 as esm2015
Compiling @angular/cdk/keycodes : es2015 as esm2015
Compiling @angular/animations : es2015 as esm2015
Compiling @angular/compiler/testing : es2015 as esm2015
Compiling @angular/cdk/observers : es2015 as esm2015
Compiling @angular/cdk/collections : es2015 as esm2015
Compiling @angular/animations/browser : es2015 as esm2015
Compiling @angular/common : es2015 as esm2015
Compiling @angular/cdk/platform : es2015 as esm2015
Compiling @angular/cdk/bidi : es2015 as esm2015
Compiling @angular/platform-browser : es2015 as esm2015
Compiling @angular/forms : es2015 as esm2015
Compiling @angular/cdk/scrolling : es2015 as esm2015
Compiling @angular/platform-browser/animations : es2015 as esm2015
Compiling @angular/cdk/a11y : es2015 as esm2015
Compiling @angular/cdk/portal : es2015 as esm2015
Compiling @angular/cdk/layout : es2015 as esm2015
Compiling @angular/common/http : es2015 as esm2015
Compiling @angular/cdk/overlay : es2015 as esm2015
Compiling @angular/cdk/text-field : es2015 as esm2015
Compiling @angular/material/core : es2015 as esm2015
Compiling @angular/cdk/accordion : es2015 as esm2015
Compiling @angular/cdk/stepper : es2015 as esm2015
Compiling @angular/cdk/table : es2015 as esm2015
Compiling @angular/cdk/tree : es2015 as esm2015
Compiling @angular/core/testing : es2015 as esm2015
Compiling @angular/material/form-field : es2015 as esm2015
Compiling @angular/material/button : es2015 as esm2015
Compiling @angular/material/icon : es2015 as esm2015
Compiling @angular/material/select : es2015 as esm2015
Compiling @angular/material/tooltip : es2015 as esm2015
Compiling @angular/material/dialog : es2015 as esm2015
Compiling @angular/material/input : es2015 as esm2015
Compiling @angular/material/divider : es2015 as esm2015
Compiling @angular/material/paginator : es2015 as esm2015
Compiling @angular/material/sort : es2015 as esm2015
Compiling @angular/platform-browser-dynamic : es2015 as esm2015
Compiling @angular/common/testing : es2015 as esm2015
Compiling @angular/router : es2015 as esm2015
Compiling @angular/animations/browser/testing : es2015 as esm2015
Compiling @angular/cdk/clipboard : es2015 as esm2015
Compiling @angular/cdk/drag-drop : es2015 as esm2015
Compiling @angular/common/http/testing : es2015 as esm2015
Compiling @angular/material/autocomplete : es2015 as esm2015
Compiling @angular/material/badge : es2015 as esm2015
Compiling @angular/material/bottom-sheet : es2015 as esm2015
Compiling @angular/material/button-toggle : es2015 as esm2015
Compiling @angular/material/card : es2015 as esm2015
Compiling @angular/material/checkbox : es2015 as esm2015
Compiling @angular/material/chips : es2015 as esm2015
Compiling @angular/material/datepicker : es2015 as esm2015
Compiling @angular/material/expansion : es2015 as esm2015
Compiling @angular/material/grid-list : es2015 as esm2015
Compiling @angular/material/icon/testing : es2015 as esm2015
Compiling @angular/material/list : es2015 as esm2015
Compiling @angular/material/menu : es2015 as esm2015
Compiling @angular/material/progress-bar : es2015 as esm2015
Compiling @angular/material/progress-spinner : es2015 as esm2015
Compiling @angular/material/radio : es2015 as esm2015
Compiling @angular/material/sidenav : es2015 as esm2015
Compiling @angular/material/slide-toggle : es2015 as esm2015
Compiling @angular/material/slider : es2015 as esm2015
Compiling @angular/material/snack-bar : es2015 as esm2015
Compiling @angular/material/stepper : es2015 as esm2015
Compiling @angular/material/table : es2015 as esm2015
Compiling @angular/material/tabs : es2015 as esm2015
Compiling @angular/material/toolbar : es2015 as esm2015
Compiling @angular/material/tree : es2015 as esm2015
Compiling @angular/platform-browser-dynamic/testing : es2015 as esm2015
Compiling @angular/router/testing : es2015 as esm2015
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\webpack-dev-server\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN @angular/core@11.0.0 requires a peer of zone.js@~0.10.3 but none is installed. You must install peer dependencies yourself.
npm WARN @ngtools/webpack@11.0.0 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/eslint-plugin@4.7.0 requires a peer of eslint@^5.0.0 || ^6.0.0 || ^7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/eslint-plugin-tslint@4.7.0 requires a peer of eslint@^5.0.0 || ^6.0.0 || ^7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/eslint-plugin-tslint@4.7.0 requires a peer of tslint@^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/parser@4.7.0 requires a peer of eslint@^5.0.0 || ^6.0.0 || ^7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/experimental-utils@4.7.0 requires a peer of eslint@* but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-middleware@3.7.2 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
added 1430 packages from 679 contributors and audited 1442 packages in 127.706s
79 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
~\..\monorepo-new webpack-5-issue npm run dev
> web-app-edit@0.0.0-PLACEHOLDER dev C:\Users\me\repo\monorepo-new
> npm run webpack-dev-server -- --config config/webpack.dev.ts --color --hot
> web-app-edit@0.0.0-PLACEHOLDER webpack-dev-server C:\Users\me\repo\monorepo-new
> node --max_old_space_size=8192 node_modules/webpack/bin/webpack serve "--config" "config/webpack.dev.ts" "--color" "--hot"
C:\Users\me\repo\monorepo-new\node_modules\webpack\lib\cache\ResolverCachePlugin.js:232
for (const callback of callbacks) {
^
TypeError: callbacks is not iterable
at done (C:\Users\me\repo\monorepo-new\node_modules\webpack\lib\cache\ResolverCachePlugin.js:232:34)
at C:\Users\me\repo\monorepo-new\node_modules\webpack\lib\cache\ResolverCachePlugin.js:161:28
at jobError (C:\Users\me\repo\monorepo-new\node_modules\webpack\lib\FileSystemInfo.js:1559:5)
at C:\Users\me\repo\monorepo-new\node_modules\webpack\lib\FileSystemInfo.js:1795:8
at C:\Users\me\repo\monorepo-new\node_modules\webpack\lib\util\AsyncQueue.js:104:29
at processTicksAndRejections (internal/process/task_queues.js:79:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! web-app-edit@0.0.0-PLACEHOLDER webpack-dev-server: `node --max_old_space_size=8192 node_modules/webpack/bin/webpack serve "--config" "config/webpack.dev.ts" "--color" "--hot"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the web-app-edit@0.0.0-PLACEHOLDER webpack-dev-server script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\me\AppData\Roaming\npm-cache\_logs\2020-11-17T13_11_35_937Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! web-app-edit@0.0.0-PLACEHOLDER dev: `npm run webpack-dev-server -- --config config/webpack.dev.ts --color --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the web-app-edit@0.0.0-PLACEHOLDER dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\me\AppData\Roaming\npm-cache\_logs\2020-11-17T13_11_36_067Z-debug.log
Describe the bug
I've just upgraded from v4 to v5 and have stumbled upon this error:
According to the source code it assumes that it can only be and
array
orundefined
even thoughfalse
is set in the code itself. It might be a another bug causing thefalse
, but it should be handled, right?What is the current behavior?
It fails every time I start my DevServer.
To Reproduce
Steps to reproduce the behavior:
We have a pretty complex setup with a monorepo. It's going to be hard to share. But if it's needed to fix the code I guess I can put in the time.
Expected behavior
Build should not fail when I start my DevServer
Please paste the results of
webpack-cli info
here, and mention other relevant information System: OS: Windows 10 10.0.17763 CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz Memory: 4.54 GB / 15.81 GB Binaries: Node: 12.16.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.16.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD Browsers: Chrome: 86.0.4240.111 Edge: Spartan (44.17763.831.0) Internet Explorer: 11.0.17763.771