question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sync store initial file-system cache when idleTimeoutForInitialStore is zero

See original GitHub issue

Feature 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 done hook 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:open
  • Created 9 months ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
SuperOleg39commented, Dec 22, 2022

Interesting idea with plugin, thank you!

0reactions
alexander-akaitcommented, Dec 21, 2022

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 idle is 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cache - webpack
idleTimeoutForInitialStore option is only available when cache.type is set to 'filesystem' . webpack.config.js module.exports = { ...
Read more >
Prompt and Error on compilation · Issue #2559 · laravel-mix ...
Different names will lead to different coexisting caches. √ --cache-store: When to store data to the filesystem. (pack: Store data when ...
Read more >
Linux Disk Cache was always there… - Medium
In Linux when we create a file, that file is initially written to page cache and only after some time or condition the...
Read more >
webpack - Fig.io
--cache-idle-timeout-for-initial-store <value> ... Time for which unused cache entries stay in the filesystem cache at minimum (in milliseconds).
Read more >
webpack-cli - npm
Latest version: 4.10.0, last published: 4 months ago. ... --cache-idle-timeout-for-initial-store number Time in ms after which idle period ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found