Skip to content
This repository has been archived by the owner on Feb 7, 2022. It is now read-only.

[BUG] parallel-webpack does not work well with webpack 5 cache persistent #111

Open
sunchanglong opened this issue Jan 13, 2021 · 2 comments

Comments

@sunchanglong
Copy link

Explain the problem

use ('parallel-webpack').run to compile multiple webpack configs with cache filesystem options
paralell-webpack run options

{
    watch: false,
    maxRetries: 1,
    stats: false, // defaults to false
    maxConcurrentWorkers: 2 // use 2 workers
}

Expected Behaviour

create .cache directory

Actual Behaviour

does not create .cache directory

Steps to reproduce

set run method options 

{
    watch: false,
    maxRetries: 1,
    stats: false, // defaults to false
    maxConcurrentWorkers: 2 // use 2 workers
}

note: it will create .cache directory if set stats: true

Provide your webpack config

Provide your Environment details

  • Node version:

  • Operating System:

  • webpack version: 5.11.1

  • parallel-webpack version: 2.6.0

@sunchanglong sunchanglong changed the title parallel-webpack does not work well with webpack 5 cache persistent [BUG]: parallel-webpack does not work well with webpack 5 cache persistent Jan 13, 2021
@sunchanglong sunchanglong changed the title [BUG]: parallel-webpack does not work well with webpack 5 cache persistent [BUG] parallel-webpack does not work well with webpack 5 cache persistent Jan 13, 2021
@wearebear80
Copy link

wearebear80 commented Mar 17, 2021

I have the same problem. Yes - persistent cache directory created if i set stats: true , but cache not working - my build time does not change :(

pure webpack build time: 1 min 30 sec
webpack + persistent cache build time: 35 sec
parallel-webpack (two parallel builds) build time: 1 min 30 sec
parallel-webpack + persistent cache (two parallel builds) build time: 1 min 30 sec

I tried to find the problem and i think its cause this JSON.stringify, but i'm not sure

done(null, options.stats ? JSON.stringify(stats.toJson(outputOptions), null, 2) : '');

if i provide pure stats to done callback like:

done(null, stats)

persistent cache working fine, but my tasks does't exit from the process - my task freezes forever
Maybe its because webpack cache working with stats in deferred webpack-hook, but its just a guess

I will try to write a similar issue to webpack repo and will attach a link here.

@filmic
Copy link

filmic commented Apr 6, 2021

In Webpack 5 compiler must be closed so that low-priority work (like persistent caching) have the opportunity to complete.
https://webpack.js.org/migrate/5/#cleanup-the-code
https://webpack.js.org/api/node/#run

Wrapping the done() call in webpackWorker.js with compiler.close()solved the problem for me:

compiler.close((closeErr) => {
	if (closeErr) console.error('Close error occured', closeErr);
	cleanup();
	if (disconnected) {
		return;
	}
	done(null, options.stats ? JSON.stringify(stats.toJson(outputOptions), null, 2) : '');
});

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

No branches or pull requests

3 participants