Skip to content

Commit 6c8a5a2

Browse files
authored
perf: flush compile cache after 10s (#19537)
1 parent beaf7e8 commit 6c8a5a2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/vite/bin/vite.js

+9
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ function start() {
4949
try {
5050
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- it is supported in Node 22.8.0+ and only called if it exists
5151
module.enableCompileCache?.()
52+
// flush the cache after 10s because the cache is not flushed until process end
53+
// for dev server, the cache is never flushed unless manually flushed because the process.exit is called
54+
// also flushing the cache in SIGINT handler seems to cause the process to hang
55+
setTimeout(() => {
56+
try {
57+
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- it is supported in Node 22.12.0+ and only called if it exists
58+
module.flushCompileCache?.()
59+
} catch {}
60+
}, 10 * 1000).unref()
5261
} catch {}
5362
return import('../dist/node/cli.js')
5463
}

0 commit comments

Comments
 (0)