Fix memory leak in dev server

This commit is contained in:
2026-10-16 14:25:18 +01:00
parent 3d0771f2d0
commit 5dc783fe97
36 changed files with 642 additions and 406 deletions
+3 -6
View File
@@ -8,6 +8,7 @@ import path from "path";
import grabDirNames from "../../utils/grab-dir-names";
import grabRelativePath from "../../utils/grab-relative-path";
import { RequestBodyTooLargeError } from "../../utils/read-request-body";
import importFresh from "../../utils/import-fresh";
const { ROOT_DIR } = grabDirNames();
export default async function ({ req }) {
try {
@@ -29,18 +30,14 @@ export default async function ({ req }) {
});
}
let module;
const now = Date.now();
const relative_match_path = grabRelativePath(match.filePath);
if (is_dev &&
global.BUNEXT_SSR_BUNDLER_CTX_MAP?.[relative_match_path]?.path) {
const target_import = path.join(ROOT_DIR, global.BUNEXT_SSR_BUNDLER_CTX_MAP[relative_match_path].path);
module = await import(`${target_import}?t=${now}`);
module = await importFresh(target_import);
}
else {
const import_path = is_dev
? `${match.filePath}?t=${now}`
: match.filePath;
module = await import(import_path);
module = await importFresh(match.filePath);
}
const config = module.config;
const maxBodyBytes = config?.max_request_body_mb