fix(engine): use static import for os.totalmem in ESM config

Replace dynamic require("os") with static import — require is undefined
in native ESM, causing the try/catch to silently return the 16GB
fallback on every machine. The cache scaling was dead code.
This commit is contained in:
Miguel Ángel
2026-05-25 15:37:13 -04:00
parent c8ed90fa21
commit 0620fa908d
+3 -5
View File
@@ -6,6 +6,8 @@
* fallbacks for backward compatibility during migration.
*/
import { totalmem } from "os";
/**
* Full engine configuration. All fields are wired through the config
* object; env vars serve as backward-compatible fallbacks resolved
@@ -209,11 +211,7 @@ export const DEFAULT_CONFIG: EngineConfig = {
};
function getSystemTotalMb(): number {
try {
return Math.floor(require("os").totalmem() / (1024 * 1024));
} catch {
return 16384;
}
return Math.floor(totalmem() / (1024 * 1024));
}
function memoryAdaptiveCacheLimit(): number {