Skip to content

Commit

Permalink
perf: flush compile cache after 10s (#19537)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Mar 3, 2025
1 parent beaf7e8 commit 6c8a5a2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/vite/bin/vite.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ function start() {
try {
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- it is supported in Node 22.8.0+ and only called if it exists
module.enableCompileCache?.()
// flush the cache after 10s because the cache is not flushed until process end
// for dev server, the cache is never flushed unless manually flushed because the process.exit is called
// also flushing the cache in SIGINT handler seems to cause the process to hang
setTimeout(() => {
try {
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- it is supported in Node 22.12.0+ and only called if it exists
module.flushCompileCache?.()
} catch {}
}, 10 * 1000).unref()
} catch {}
return import('../dist/node/cli.js')
}
Expand Down

0 comments on commit 6c8a5a2

Please # to comment.