Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Production build hangs at 92% #272

Closed
melloc01 opened this issue Apr 3, 2018 · 103 comments
Closed

Production build hangs at 92% #272

melloc01 opened this issue Apr 3, 2018 · 103 comments

Comments

@melloc01
Copy link

melloc01 commented Apr 3, 2018

Hello,

I think this is probably a bug with this plugin since the dev build works fine and when I run webpack --progress it gets stuck in:

92% chunk asset optimization UglifyJSPlugin

Below, the relevant parts of my webpack.config:

....

module.exports = {
    mode,
    node: { fs: 'empty' },
    entry: {
        ...entries
    },

    output: {
        filename: '[name].js',
        path: path.join(__dirname, '/public/assets/')
    },

    module: {
        rules: [
            {
                test: /\.js?$/,
                exclude: /(node_modules)/,
                use: 'babel-loader'
            },
            {
                test: /\.(scss|css)$/,
                use: [
                    MiniCssExtractPlugin.loader,

                    {
                        loader: 'css-loader'
                    },
                    {
                        loader: 'sass-loader',
                        options: {
                            sourceMap: true
                        }
                    }
                ]
            }
        ]
    },

    plugins: [
        new MiniCssExtractPlugin({
            filename: '[name].css'
        })
    ],

    resolve: {
        alias: {
            core: path.join(__dirname, 'js/core')
        }
    },

    optimization: {
        splitChunks: {
            minSize: 100000,
            chunks: 'initial',
            maxAsyncRequests: Infinity,
            maxInitialRequests: Infinity,
            name: true,
            cacheGroups: {
                styles: {
                    name: 'core',
                    test: /\.(scss|css)$/,
                    chunks: 'all',
                    enforce: true
                },
                vendor: {
                    name: 'vendor',
                    test: function (module) {
                        return /\/node_modules\//.test(module.context)
                    }
                },
                'core': {
                    name: 'core',
                    test: function (module) {
                        return /live-core\//.test(module.context)
                    }
                }
            }
        }
    }
}

Is this enough info? I tried to run with --debug --progress --display-error-details --verbose but nothing else came out

@melloc01
Copy link
Author

melloc01 commented Apr 3, 2018

Well, I post the config in case there is an error on it - if you don't spot an error I can create a repo that reproduces the error,

Thanks in advance 😊

@melloc01
Copy link
Author

melloc01 commented Apr 3, 2018

Instead of using the build-in module from webpack, when actually use the plugin on my webpack-config.js adding it to the plugins array and in dev mode, it works as expected, productionfails again.
Perhaps it's related to webpack.. 🤔

@melloc01
Copy link
Author

melloc01 commented Apr 3, 2018

Still experimenting...

Using -p seems to be the reason that I get stuck. (maybe it's the only way to activate the plugin?)

Using https://github.com/pingyuanChen/webpack-uglify-js-plugin works on -p mode, it was the workaround to get going for now

@alexander-akait
Copy link
Member

@melloc01 can you create minimum reproducible test repo?

@alexander-akait
Copy link
Member

@melloc01 Friendly ping 👍

@melloc01
Copy link
Author

melloc01 commented Apr 6, 2018

Thanks @evilebottnawi
Did not forget - just overloaded with other upgrade issues. HMR now :|

Will save some time on the weekend to set up the repo

News: someone on Gitter is having the same issue

@zlk89
Copy link

zlk89 commented Apr 7, 2018

Same here, and I get out of memory error after a while:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

This error happens to me every time I tried to use UglifyJSPlugin.

My dependencies:

{
    "autodll-webpack-plugin": ">=0.3.9",
    "autoprefixer": ">=8.2.0",
    "babel-loader": ">=8.0.0-beta.2",
    "babel-plugin-import": ">=1.7.0",
    "circular-dependency-plugin": ">=5.0.1",
    "compression-webpack-plugin": ">=1.1.11",
    "css-loader": ">=0.28.11",
    "file-loader": ">=1.1.11",
    "font-loader": ">=0.1.2",
    "happypack": ">=5.0.0-beta.3",
    "html-webpack-plugin": ">=3.2.0",
    "lodash": ">=4.17.5",
    "null-loader": ">=0.1.1",
    "postcss-loader": ">=2.1.3",
    "preload-image-loader": ">=1.0.0",
    "react-hot-loader": ">=4.0.1",
    "resolve-url-loader": ">=2.3.0",
    "sass-loader": ">=6.0.7",
    "stats-webpack-plugin": ">=0.6.2",
    "style-loader": ">=0.20.3",
    "uglifyjs-webpack-plugin": ">=1.2.4",
    "webpack": ">=4.5.0",
    "webpack-cli": ">=2.0.14"
  }

@alexander-akait
Copy link
Member

@zlk89 do you use latest version?

@alexander-akait
Copy link
Member

@zlk89 Also please create new issue, your problem is other

@erickwilder
Copy link

I just upgraded to webpack 4 (4.5.0) and I'm experiencing the same. It takes ages to finish the build process as it gets stuck on 92%.

@alexander-akait
Copy link
Member

@erickwilder Can you crete minimum reproducible test repo?

@erickwilder
Copy link

My issue was apparently caused by the compress: true option of uglify - which is the default. Setting a custom uglify plugin instance overriding this configuration under the plugins list had no effect to change the compilation behavior.

I did solve it by moving uglify from the plugins to the optimization.minimizer list.

optimization.minimizer: [ new UglifyJsPlugin(...custom options) ]

Unfortunately this was the work of some digging through the code and other people's setup - I didn't find clear documentation about it.

@alexander-akait
Copy link
Member

@erickwilder in webpack@4 you don't use plugins for minification, use minimizer property. If you use plugin field you have 2 instance of plugin. But will be great minimum reproducible test repo. In theory it is don't hangs.

@melloc01
Copy link
Author

@evilebottnawi actually, if you specify the minimize property you just overwrite the default (built-in) UglifyJS as seen here:
https://survivejs.com/webpack/optimizing/minifying/

I actually set up a dummy repo that mimics the file structure (w/ dummy modules) of the original project but unfortunately it didn't hang, so it's not reproducible using dummy modules

I'm up for a call if you wanna dig into it @evilebottnawi, it's private so I can't just put on gh =\

@alexander-akait
Copy link
Member

@melloc01 can you add coded in uglify plugin here https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/src/index.js#L184

console.log(tasks[index]); and identify hwat task is not completed?

@melloc01
Copy link
Author

melloc01 commented Apr 10, 2018

sure - done it.

I'm using exactly this source:
https://gist.github.com/melloc01/4c34922b2e31599674a7ddff0aaa7d2d#file-uglify-index-js-L138

Output:

$ webpack --config webpack-prod.config.js --progress -p

Plugin init...
 60% building modules 420/455 modules 35 active …ore/services/config/dashboard.config.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 64% building modules 457/477 modules 20 active …modules/react-bootstrap/es/Jumbotron.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 65% building modules 475/517 modules 42 active …js/modules/main/monitoring/ui/alerts.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 67% building modules 539/564 modules 25 active …modules/react-bootstrap/es/MediaLeft.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 68% building modules 2406/2450 modules 44 active …-core/components/header/ui/main/main.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 69% building modules 2415/2453 modules 38 active …tcss/node_modules/lodash/_mapToArray.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 69% building modules 2424/2455 modules 31 active …/modules/admin/components/roles-form.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 69% building modules 2425/2459 modules 34 active …/node_modules/babel-standalone/babel.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 69% building modules 2428/2463 modules 35 active …/node_modules/sass.js/dist/sass.sync.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 69% building modules 2431/2470 modules 39 active …dules/admin/extensions/ui/pipes/form.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 68% building modules 2433/2488 modules 55 active …modules/core-js/modules/_typed-array.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 68% building modules 2436/2490 modules 54 active …/node_modules/lodash/_listCacheClear.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 68% building modules 2440/2495 modules 55 active …s/live/webapp/js/live-core/lib/types.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 68% building modules 2445/2503 modules 58 active …olor/node_modules/lodash/_hashDelete.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 68% building modules 2447/2504 modules 57 active …ve-core/components/ui/dashboard-card.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 68% building modules 2464/2510 modules 46 active …core-js/modules/_inherit-if-required.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 68% building modules 2465/2510 modules 45 active …core-js/modules/_inherit-if-required.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 68% building modules 2467/2517 modules 50 active …components/header/ui/main/my-account.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 69% building modules 2495/2524 modules 29 active …es/enquire.js/src/MediaQueryDispatch.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 69% building modules 2497/2524 modules 27 active …es/enquire.js/src/MediaQueryDispatch.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 69% building modules 2515/2545 modules 30 active …or/node_modules/lodash/_nativeCreate.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 69% building modules 2610/2628 modules 18 active …app/node_modules/miller-rabin/lib/mr.js
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 69% building modules 2710/2713 modules 3 active …e_modules/jquery-ui/themes/base/all.css 
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 69% building modules 2712/2713 modules 1 active …ael/Projects/live/webapp/sass/live.scss
After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []

After chunks reduce, before runTasks... tasks len= 0

InsideRunTask... results= []
 92% chunk asset optimization UglifyJSPlugin               
After chunks reduce, before runTasks... tasks len= 7
filename = vendor.js

@alexander-akait
Copy link
Member

alexander-akait commented Apr 10, 2018

@melloc01 very intresting, you always have zero tasks 😕 You enable parallel? If yes, can you disable and check again? If no can you enable and check again? 😄

@melloc01
Copy link
Author

Anything else than the filename to help debugging @evilebottnawi?

@melloc01
Copy link
Author

melloc01 commented Apr 10, 2018

After a while:

Same thing with parallel: false @evilebottnawi

<--- Last few GCs --->

[2509:0x2be3950]   115719 ms: Mark-sweep 1407.9 (1504.7) -> 1405.2 (1506.7) MB, 1204.8 / 0.0 ms  allocation failure GC in old space requested
[2509:0x2be3950]   117133 ms: Mark-sweep 1405.2 (1506.7) -> 1405.2 (1472.7) MB, 1413.8 / 0.0 ms  last resort GC in old space requested
[2509:0x2be3950]   118372 ms: Mark-sweep 1405.2 (1472.7) -> 1405.2 (1468.7) MB, 1237.9 / 0.0 ms  last resort GC in old space requested


<--- JS stacktrace --->

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

Security context: 0x34e23ad25501 <JSObject>
    1: push(this=0x34d6cddcc679 <JSArray[50855]>)
    2: reduce_vars [0x322b08a822d1 <undefined>:~8085] [pc=0x2244554c2807](this=0x3d7535065621 <AST_SymbolRef map = 0x7dfe33070b9>,tw=0x3716375ac559 <TreeWalker map = 0x7dfe330cde1>,descend=0x1c8762082991 <JSFunction noop (sfi = 0x1d796426e2a1)>,compressor=0x2de51d44eea1 <Compressor map = 0x2a0097b73f31>)
    3: visit [0x322b08a822d1 <undefined>:~...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [node]
 2: 0x11f155c [node]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [node]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
 5: v8::internal::Factory::NewUninitializedFixedArray(int) [node]
 6: 0xdf28df [node]
 7: 0xe05ff5 [node]
 8: v8::internal::JSObject::AddDataElement(v8::internal::Handle<v8::internal::JSObject>, unsigned int, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::Object::ShouldThrow) [node]
 9: v8::internal::Object::AddDataProperty(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::Object::ShouldThrow, v8::internal::Object::StoreFromKeyed) [node]
10: v8::internal::Object::SetProperty(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::LanguageMode, v8::internal::Object::StoreFromKeyed) [node]
11: v8::internal::Runtime_SetProperty(int, v8::internal::Object**, v8::internal::Isolate*) [node]
12: 0x2244548842fd
Aborted (core dumped)
error Command failed with exit code 134.

@melloc01
Copy link
Author

Config:

        minimizer: [
            new UglifyJsPlugin({
                cache: false,
               parallel: false
            }),
            new OptimizeCSSAssetsPlugin({})
        ]

@alexander-akait
Copy link
Member

alexander-akait commented Apr 10, 2018

@melloc01 can you idntify after what file it is happens? Just add console.log(file); here https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/src/index.js#L184. Also add console.log(this.maxConcurrentWorkers) here https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/src/uglify/index.js#L19. Thanks for help!

@melloc01
Copy link
Author

I'm back... debugging:

parallel=false

Plugin init...
 62% building modules 434/468 modules 34 active …es/react-bootstrap/es/DropdownButton.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 66% building modules 518/554 modules 36 active …t-dom/lib/renderSubtreeIntoContainer.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 68% building modules 597/616 modules 19 active …les/babel-runtime/core-js/array/from.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 68% building modules 691/707 modules 16 active …odules/core-js/library/fn/array/from.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2406/2421 modules 15 active …app/node_modules/rc-slider/lib/utils.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2410/2423 modules 13 active …/node_modules/react-slick/lib/slider.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2440/2465 modules 25 active …modules/core-js/modules/_typed-array.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2458/2493 modules 35 active …ode_modules/core-js/modules/_classof.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2458/2497 modules 39 active …ode_modules/core-js/modules/_wks-ext.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 68% building modules 2463/2512 modules 49 active …e-core/components/ui/FullScreenModal.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 68% building modules 2464/2512 modules 48 active …e-core/components/ui/FullScreenModal.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 68% building modules 2467/2515 modules 48 active …modules/core-js/modules/_iter-create.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 68% building modules 2470/2522 modules 52 active …-core/components/forms/ui/table-form.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2481/2523 modules 42 active …ode_modules/simplebar/dist/simplebar.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2489/2523 modules 34 active …ode_modules/simplebar/dist/simplebar.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2495/2523 modules 28 active …ode_modules/simplebar/dist/simplebar.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2495/2524 modules 29 active …p/node_modules/delegate/src/delegate.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2502/2526 modules 24 active …_modules/core-js/modules/_object-dps.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2503/2528 modules 25 active …de_modules/core-js/modules/_to-index.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2504/2528 modules 24 active …de_modules/core-js/modules/_to-index.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2570/2603 modules 33 active …de_modules/public-encrypt/withPublic.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2580/2607 modules 27 active …_modules/pbkdf2/lib/default-encoding.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2582/2607 modules 25 active …_modules/pbkdf2/lib/default-encoding.js
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2712/2713 modules 1 active …ael/Projects/live/webapp/sass/live.scss 
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 0
 92% chunk asset optimization UglifyJSPlugin               
maxConcurrentWorkers 0

After chunks reduce, before runTasks... tasks len= 7
filename =  vendor.js

<--- Last few GCs --->

[20574:0x382c950]   100951 ms: Mark-sweep 1382.4 (1498.1) -> 1382.3 (1499.1) MB, 1213.9 / 0.0 ms  allocation failure GC in old space requested
[20574:0x382c950]   102171 ms: Mark-sweep 1382.3 (1499.1) -> 1382.3 (1458.1) MB, 1219.6 / 0.0 ms  last resort GC in old space requested
[20574:0x382c950]   103401 ms: Mark-sweep 1382.3 (1458.1) -> 1382.3 (1454.6) MB, 1229.4 / 0.0 ms  last resort GC in old space requested
...

parallel=true

$ webpack --config webpack-prod.config.js --progress -p

Plugin init...
 67% building modules 579/606 modules 27 active …e/webapp/node_modules/isobject/index.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 68% building modules 918/940 modules 22 active …e-js/library/modules/_array-includes.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2457/2483 modules 26 active …modules/velocity-animate/velocity.ui.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2459/2485 modules 26 active …les/rc-util/lib/Dom/addEventListener.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2459/2486 modules 27 active …/node_modules/react-slick/lib/slider.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2461/2490 modules 29 active …/node_modules/babel-standalone/babel.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2463/2494 modules 31 active …/node_modules/sass.js/dist/sass.sync.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2463/2497 modules 34 active …_modules/core-js/modules/_wks-define.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2463/2499 modules 36 active …de_modules/core-js/modules/_is-array.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 68% building modules 2464/2513 modules 49 active …_modules/core-js/modules/_collection.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 68% building modules 2467/2515 modules 48 active …modules/core-js/modules/_typed-array.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 68% building modules 2467/2517 modules 50 active …odules/core-js/modules/_typed-buffer.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 68% building modules 2471/2517 modules 46 active …odules/core-js/modules/_typed-buffer.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 68% building modules 2474/2519 modules 45 active …ebapp/node_modules/select/src/select.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 68% building modules 2476/2519 modules 43 active …ebapp/node_modules/select/src/select.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2490/2520 modules 30 active …js/library/fn/object/define-property.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2492/2520 modules 28 active …js/library/fn/object/define-property.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2503/2531 modules 28 active …de_modules/core-js/modules/_to-index.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2507/2534 modules 27 active …modules/react-responsive-mixin/index.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2558/2586 modules 28 active …ebapp/node_modules/cipher-base/index.js
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2565/2589 modules 24 active …les/browserify-sign/browser/curves.json
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2568/2589 modules 21 active …les/browserify-sign/browser/curves.json
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 69% building modules 2712/2713 modules 1 active …ael/Projects/live/webapp/sass/live.scss 
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0

maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 0
 92% chunk asset optimization UglifyJSPlugin               
maxConcurrentWorkers 3

After chunks reduce, before runTasks... tasks len= 7
filename =  vendor.js

...(not dead yet)

@melloc01
Copy link
Author

Btw, I updated the gist. Look for .log('==========file======') it never reaches that point.

@alexander-akait
Copy link
Member

@melloc01 can you rewrite https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/src/uglify/worker.js#L3
on:

module.exports = (options, callback) => {
  try {
    // 'use strict' => this === undefined (Clean Scope)
    // Safer for possible security issues, albeit not critical at all here
    // eslint-disable-next-line no-new-func, no-param-reassign
    options = new Function(`'use strict'\nreturn ${options}`)();
    const minified = minify(options); 

    callback(minified.error ? 'Error' : null, minified);
  } catch (errors) {
    callback(errors);
  }
};

And run in parallels mode?

@melloc01
Copy link
Author

@evilebottnawi sorry about that last comment, it wasn't right.

Actually, I am modifying the babelified version of the plugin, so minify wasn't defined, got an error from the plugin.

on babelified version it is minify2.default

@alexander-akait
Copy link
Member

@melloc01 yep, rewrite using minify2.default and other babel stuff with save logic as above

@melloc01
Copy link
Author

Same outcome - stuck at 92% until core dump
Actually, I'm free now for faster interactions 👍

I also logged the minified object and saw that in the code there were ModuleConcatenation bailout repeating a lot. Disabling it to see if there is some change.

@alexander-akait
Copy link
Member

@melloc01 can you disable ModuleConcatenationPlugin and check again?

@melloc01
Copy link
Author

       namedModules: false,
        noEmitOnErrors: false, // NoEmitOnErrorsPlugin
        concatenateModules: false, // ModuleConcatenationPlugin

It seems that it is getting stuck in somewhere else @evilebottnawi ... I changed the worker code to this:

'use strict'

var _minify = require('./minify')

var _minify2 = _interopRequireDefault(_minify)

function _interopRequireDefault (obj) {
    return obj && obj.__esModule ? obj : { default: obj }
}

module.exports = function (options, callback) {
    try {
        // 'use strict' => this === undefined (Clean Scope)
        // Safer for possible security issues, albeit not critical at all here
        // eslint-disable-next-line no-new-func, no-param-reassign
        options = new Function(`'use strict'\nreturn ${options}`)()
        console.warn('')
        console.warn('options =', options.file)
        const minified = _minify2.default(options)

        console.warn('after options')
        console.warn('')

        /*
          Options:
          [ 'file',
  'input',
  'inputSourceMap',
  'commentsFile',
  'extractComments',
  'uglifyOptions' ]

        */

        callback(minified.error ? 'Error' : null, minified)
    } catch (errors) {
        callback(errors)
    }'use strict'

var _minify = require('./minify')

var _minify2 = _interopRequireDefault(_minify)

function _interopRequireDefault (obj) {
    return obj && obj.__esModule ? obj : { default: obj }
}

module.exports = function (options, callback) {
    try {
        // 'use strict' => this === undefined (Clean Scope)
        // Safer for possible security issues, albeit not critical at all here
        // eslint-disable-next-line no-new-func, no-param-reassign
        options = new Function(`'use strict'\nreturn ${options}`)()
        console.warn('')
        console.warn('options =', options.file)
        const minified = _minify2.default(options)

        console.warn('after options')
        console.warn('')

        /*
          Options:
          [ 'file',
  'input',
  'inputSourceMap',
  'commentsFile',
  'extractComments',
  'uglifyOptions' ]

        */

        callback(minified.error ? 'Error' : null, minified)
    } catch (errors) {
        callback(errors)
    }
}

}

and the output:

After chunks reduce, before runTasks... tasks len= 0
 92% chunk asset optimization UglifyJSPlugin               
After chunks reduce, before runTasks... tasks len= 7
filename =  vendor.js

options = admin.js

options = live.js

options = vendor.js
after options


options = dashboard.js
after options

after options


options = main.js
after options

It's stuck consuming memory right now

@elie222
Copy link

elie222 commented Sep 4, 2018

Same issue?
angular/angular-cli#5775

@petercunha
Copy link

Getting the same issue on the latest Angular version. My build has been hanging for almost 10 minutes now...

@marcins
Copy link

marcins commented Oct 3, 2018

We're seeing this issue too - we've narrowed it down to source maps being the issue in our case. We have a lot of code (if I run Webpack without minifcation it produces some 600MB of JS) however if we turn on sourceMaps for Uglify in this build it effectively hangs. We're already running with extra heap as well.

I've found a few things that could be potential areas for improvement:

  • source maps are kept in memory in the task object (the inputSourceMap property), serialised, and passed to workers. This is adding a significant amount of memory pressure in our case - if caching is enabled would it make sense to write the inputSourceMap to disk instead and just store a reference to the filename in the task? It would then be read from disk in the worker.
  • sourcemaps are produced serially - could this also be parallelised using the TaskRunner? I'm seeing long periods of "only" 100% CPU usage while sourcemaps are generated.

I am still experimenting with improvements locally, to see whether there is actually significant impact, but wondering what the appetite for these kinds of changes would be?

@marcins
Copy link

marcins commented Oct 5, 2018

After investigating this more it's not as easy as it seems - within wepback-sources (where the code for sourceAndMap exists) the source map is also cached in memory. So removing it from memory in the uglify plugin won't make a difference to memory usage as it's still retained within the asset.

Unfortunately, I don't think there's much that can be done with the current architecture to alleviate the memory pressure - I believe there's more significant architectural changes planned for Webpack 5 that'll move more caching to disk.

In the meantime I've had a bit more success with using the cheap-module-source-map - it's still not as fast as Webpack 3 for our build, but at least it completes and doesn't OOM.

I didn't get around to trying parallelising source map generation.

Important to note that all these results are running a custom fork of uglifyjs-webpack-plugin that uses the new version of source-map - there is a serious performance issue in the version that ships with the plugin, essentially half the runtime is spent doing .split(/\\+/) - the new version replaces this with a non-regex method. It's a different issue (#248), I wonder if that perf fix could be backported to a version of source-map that's still Node 6 compatible.

@benthemonkey
Copy link

@marcins I followed your suggestion and opened an issue to backport the performance fix to 0.6 (mozilla/source-map#370)

@normana400
Copy link

normana400 commented Nov 19, 2018

I've noticed that this will manifest if there is a discrepancy between a slick table definition and the case class that represents the row. In my case it was a column defined as a Option[String] while the case class attribute was an Option[Long].
Instead of causing a compile error what actually happens is the compiler will hang one it starts to compile the slick based persistence and will run until it eventually hits its memory limit.
So if that happens to you it could be a code issue and not a Java / SBT / eclipse setting

@Bonbons
Copy link

Bonbons commented Dec 3, 2018

I had the same problem.
I am solved by correcting a regex. I suppressed all "Named capturing group" regex feature.
And, it work again...

@Bonbons
Copy link

Bonbons commented Dec 3, 2018

The problem is that Uglify does not say that it loops on a regex.

@sumantka
Copy link

Does anyone know if this issue got fixed. We're still experiencing it.

@mlavina
Copy link

mlavina commented May 29, 2019

@sumantka unfortunately we couldn't get this fixed on the main uglify branch, but the community has decided to fork uglify and make a new minifier called terser. It should be identical except terser is more optimized and effecient. If you look at webpack docs they even only recommend the terser plugin. There should be no work switching other then actually using a different loader and plugin because again this was a fork of uglify

@sumantka
Copy link

Thanks @mlavina Unfortunately that doesn't seem to be the issue, or atleast that's what it looks like. It seems webpack by default adds some plugins in prod mode, terser is one. Now it seems to be failing at that. So not sure if it's inherently a problem of terser or some other plugin. Thanks for the context though

@melloc01
Copy link
Author

melloc01 commented Jun 6, 2019

@sumantka after I switched to Terser I didn't experience the issue anymore, check if you're not forcing uglifyjs as a minifier on your config maybe? Otherwise I think you should open an issue on the Terser repo.

@knapcio
Copy link

knapcio commented Jun 26, 2019

Temp solution, just to make it work (without minifying): Setting chunkFilter: () => false solved the problem for me:

const TerserPlugin = require('terser-webpack-plugin');

optimization: {
  minimizer: [
    new TerserPlugin({
      chunkFilter: () => false, // <-- set to false
    }),
  ],
},

@ReinisV
Copy link

ReinisV commented Jun 26, 2019

Setting chunkFilter: () => false solved the problem for me

I'm pretty sure that turns off minifying altogether.

From the main readme of the repo:

chunkFilter

Type: Function<(chunk) -> boolean>
Default: () => true

Allowing to filter which chunks should be uglified (by default all chunks are uglified).
Return true to uglify the chunk, false otherwise.

I'm 99% sure that 'uglified' and 'uglify' in this context means 'apply the plugin to minify the code of the chunk'.

I doubt you want to turn off minifying completely, @knapcio?

@alexander-akait
Copy link
Member

alexander-akait commented Jun 26, 2019

Problem inside uglifyjs, they have problem(s) in code where you get infinity loop and webpack is freeze, no workaround for this plugin, please use terser-webpack-plugin

@papiro
Copy link

papiro commented Oct 1, 2019

I came to this thread because I am experiencing the issue after having just migrated from Webpack v2 to v4, but not using Uglify at all. Just using the default minimizer. mode is production.

@alexander-akait
Copy link
Member

@papiro do you use WSL?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests