Sync store initial file-system cache when idleTimeoutForInitialStore is zero
See original GitHub issueFeature request
What is the expected behavior?
When parameter idleTimeoutForInitialStore set to 0 for file-system caches, force write initial cache on disk immediately after build, for now it will be still async.
What is motivation or use case for adding/changing the behavior?
We use webpack in jest test suites - have a lot of small SSR applications for testing specific features, and for every test suite in setup hooks we build this application once.
And this tests are unstable, because of unpredictable cache persisting behaviour and timings (no way to wait before it will finished):
- we start application build
- wait for
donehook before start test suite - Jest run test cases
- somewhere in the middle of testing process webpack starting write caches on disk
- Node.js event loop blocks for 1-2 seconds
- requests fails on timeouts
How should this be implemented in your opinion?
When cache: { idleTimeoutForInitialStore: 0 }, run initial cache store synchronously on afterDone hook
Are you willing to work on this yourself?
Not sure because of complex idle tasks flow
Issue Analytics
- State:
- Created 9 months ago
- Comments:5 (3 by maintainers)

Top Related StackOverflow Question
Interesting idea with plugin, thank you!
I see, I think we can implement this using a different name, but it requires to rewrite many things, because our hooks are async for cache for better perf.
In theory it can be solved by a custom plugin, because
idleis just a plugin https://github.com/webpack/webpack/blob/main/lib/cache/IdleFileCachePlugin.js#L15, so you can disable cache and enable cache using plugins (like here https://github.com/webpack/webpack/blob/main/lib/WebpackOptionsApply.js#L623) in your configuration with own idle plugin