Fix memory leak in dev server
This commit is contained in:
+8
-7
@@ -3,6 +3,8 @@ import allPagesESBuildContextBundler from "../bundler/all-pages-esbuild-context-
|
||||
import serverPostBuildFn from "./server-post-build-fn";
|
||||
import { restartWatcher } from "./watcher-esbuild-ctx";
|
||||
import { logBuildErrorsOnce } from "../../utils/build-error-log";
|
||||
import disposeBundlerContexts from "../bundler/dispose-bundler-contexts";
|
||||
import isDevelopment from "../../utils/is-development";
|
||||
// Single-flight: error recovery paths (grab-page-component retries, the
|
||||
// watcher, post-build HMR pushes) all call fullRebuild, and each rebuild
|
||||
// triggers serverPostBuildFn which can re-enter error handling. Without this
|
||||
@@ -33,18 +35,17 @@ async function doFullRebuild(params) {
|
||||
log.watch(msg);
|
||||
}
|
||||
global.BUNEXT_ROUTER.reload();
|
||||
try {
|
||||
await global.BUNEXT_BUNDLER_CTX?.dispose();
|
||||
global.BUNEXT_BUNDLER_CTX = undefined;
|
||||
await global.BUNEXT_SSR_BUNDLER_CTX?.dispose();
|
||||
global.BUNEXT_SSR_BUNDLER_CTX = undefined;
|
||||
}
|
||||
catch (error) { }
|
||||
await disposeBundlerContexts();
|
||||
await allPagesESBuildContextBundler({
|
||||
post_build_fn: async (params) => {
|
||||
await serverPostBuildFn(params);
|
||||
},
|
||||
});
|
||||
// Production never rebuilds incrementally; don't keep esbuild's
|
||||
// build state alive for the rest of the process.
|
||||
if (!isDevelopment()) {
|
||||
await disposeBundlerContexts();
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
logBuildErrorsOnce([{ text: error?.message || String(error) }], (line) => log.error(line));
|
||||
|
||||
Reference in New Issue
Block a user