PatrickJS-starter icon indicating copy to clipboard operation
PatrickJS-starter copied to clipboard

webpack is really really slow and sometimes crashes with OOM

Open fxck opened this issue 10 years ago • 51 comments

I haven't really messed with any of the configs, yet after adding a couple of components the build times are getting incredibly long(around 40 sec is no exception), that is on the first run of npm run server, after a while(few changes in files, watch triggered couple of times), it will get stuck on 90% optimize assets and then crash with the error below.

I'm really not sure how to debug this, and I'm not aware of doing something hacky in my code(there are no typescript errors at very least, and I'm not aware of any cycle dependency either) that could possibly cause it to go mental like this.

How should I proceed? Are there any common mistakes that would cause this, and I should look for? Would it help if I posted my repo? :|

I'm running the latest version of angular2-webpack-starter and node 5.7.0

 90% optimize assets
<--- Last few GCs --->

  282958 ms: Mark-sweep 1378.9 (1456.7) -> 1381.9 (1456.7) MB, 2960.5 / 0 ms [allocation failure] [GC in old space requested].
  285856 ms: Mark-sweep 1381.9 (1456.7) -> 1381.9 (1456.7) MB, 2898.3 / 0 ms [allocation failure] [GC in old space requested].
  288814 ms: Mark-sweep 1381.9 (1456.7) -> 1377.1 (1456.7) MB, 2957.6 / 0 ms [last resort gc].
  291789 ms: Mark-sweep 1377.1 (1456.7) -> 1378.6 (1456.7) MB, 2975.3 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0xff19f0e3ac1 <JS Object>
    1: copyMap [/srv/bubble/users/ar/ng2-base/repo/node_modules/typescript/lib/typescript.js:1198] [pc=0x3b78ca2abb95] (this=0x36735faa3a1 <an Object with map 0x1c3192bf1da1>,source=0x1a165d296929 <an Object with map 0x1c3192bbc3a1>,target=0x9118a8a3ef1 <an Object with map 0x2b40e4710441>)
    2: objectTypeRelatedTo(aka objectTypeRelatedTo) [/srv/bubble/users/ar/ng2-base/repo/node_modules/typesc...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
Aborted

fxck avatar Mar 02 '16 08:03 fxck

I've seen this error over and over again as well. I've had it fail on module build steps as well as optimize assets.

jkyoutsey avatar Mar 02 '16 17:03 jkyoutsey

I upgraded my package.json this morning and got the same errors. So I'm going to roll back where it was. Something is clearly broken. And it's not typescript, I checked.

alvipeo avatar Mar 02 '16 20:03 alvipeo

I've managed to get my dev build working, but npm run build:prod fails at the same point every time. I've tried upping the memory limit on node to no avail. node --max_old_space_size=8092 ./node_modules/webpack/bin/webpack.js

jkyoutsey avatar Mar 02 '16 20:03 jkyoutsey

@alvipeo I tried it at different points of time, not with just the latest version, and it always incrementally slows down(build times that is), and eventually starts crashing... Basically fresh webpack starter takes about 5 seconds to build, 10 component and couple of services later (all in all somewhere about 300 LOC in total), it takes 40 seconds and is crashing. It's impossible to develop like this..

fxck avatar Mar 02 '16 20:03 fxck

I completely agree with you. I've been a Microsoft tools user for a long time so I used to higher level quality dev tools. But had to switch to this "modern" build tools 6 months ago and it sucks. From configuration to the actual usage. Except for VS Code which is really fast!

Having said all that, we have no choice for now I guess :( There's also rollupjs and babel. But I have no will and time to spend that much time on this...

alvipeo avatar Mar 02 '16 21:03 alvipeo

I'm curious, are you guys on Windows or Mac?

alvipeo avatar Mar 02 '16 21:03 alvipeo

I am on Mac.

jkyoutsey avatar Mar 02 '16 21:03 jkyoutsey

ok, I thought maybe it's just Windows. It's not..

alvipeo avatar Mar 02 '16 21:03 alvipeo

Okay, I've eliminated this error in my prod builds by commenting out the new ProvidePlugin({...}) in the webpack.prod.config. This gets my prod builds working. But it doesn't stop the hot recompile hang.

jkyoutsey avatar Mar 02 '16 22:03 jkyoutsey

Did not work for me.

alvipeo avatar Mar 02 '16 23:03 alvipeo

@alvipeo Not surprised. For as often as my dev build fails on hot recompiles I was surprised I got anything to work.

jkyoutsey avatar Mar 02 '16 23:03 jkyoutsey

@gdi2290 any chance you'd look into this, please? At least tell us whether this could possibly have something to do with how angular-webpack-starter is set up, or it's rather a webpack/typescript problem and we should fill issues in their respective repos..

fxck avatar Mar 03 '16 10:03 fxck

+1 Also seeing this.

sumigoma avatar Mar 05 '16 06:03 sumigoma

I find it really moody, sometimes it works flawlessly, I comment out one innocent line of code and it crashes...

fxck avatar Mar 07 '16 09:03 fxck

the CompressionPlugin and ProvidePlugin plugins might be eating up a lot of memory

PatrickJS avatar Mar 07 '16 09:03 PatrickJS

Those are not in dev server, are they? And it crashes in dev as well..

fxck avatar Mar 07 '16 09:03 fxck

Don't have them either and the build crashes... :(

alvipeo avatar Mar 07 '16 09:03 alvipeo

it might be webpackMerge and the default config I introduced

PatrickJS avatar Mar 07 '16 09:03 PatrickJS

Can we roll back a bit?

alvipeo avatar Mar 07 '16 09:03 alvipeo

can you try it now? https://github.com/AngularClass/angular2-webpack-starter/commit/fe37a03b6e86fa7ceeb9c76e0cc59db3eb2b8d83

PatrickJS avatar Mar 07 '16 09:03 PatrickJS