Stop per-request module re-imports leaking memory in production
Page rendering imported the SSR bundle and .server.ts modules with a unique ?t= query on every request, in production too. Each one became a new, never-evicted module record (and re-ran module top-level code), so RSS grew with request count. Cache-bust only in dev via importFresh. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+3
-3
@@ -3,8 +3,8 @@ import _ from "lodash";
|
||||
import { log } from "../../../utils/log";
|
||||
import grabRootFilePath from "./grab-root-file-path";
|
||||
import grabPageCombinedServerRes from "./grab-page-combined-server-res";
|
||||
import importFresh from "../../../utils/import-fresh";
|
||||
export default async function grabPageModules({ file_path, debug, url, query, routeParams, skip_server_res, }) {
|
||||
const now = Date.now();
|
||||
const { serverRes } = skip_server_res
|
||||
? {}
|
||||
: await grabPageCombinedServerRes({
|
||||
@@ -33,8 +33,8 @@ export default async function grabPageModules({ file_path, debug, url, query, ro
|
||||
const { root_file_path } = grabRootFilePath();
|
||||
const root_module = !root_file_path
|
||||
? undefined
|
||||
: bundled_root_module || (await import(`${root_file_path}?t=${now}`));
|
||||
const module = page_module || (await import(`${file_path}?t=${now}`));
|
||||
: bundled_root_module || (await importFresh(root_file_path));
|
||||
const module = page_module || (await importFresh(file_path));
|
||||
if (debug) {
|
||||
log.info(`module:`, module);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user