From 28f948aa7dc52a41eb1b58636130c43759a2fdf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Mon, 25 May 2026 19:34:47 +0000 Subject: [PATCH] fix(engine): use static import for execSync, unify VRAM cap at 16GB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace require("child_process") with static import (same ESM fix as config.ts — require is undefined in native ESM) - Unify cap: both VRAM probe and heuristic paths now cap at 16GB - Add comment noting the one-time blocking execSync is cached --- packages/engine/src/services/browserManager.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/engine/src/services/browserManager.ts b/packages/engine/src/services/browserManager.ts index 0361dfce6..9e60bbe20 100644 --- a/packages/engine/src/services/browserManager.ts +++ b/packages/engine/src/services/browserManager.ts @@ -6,6 +6,7 @@ */ import type { Browser, PuppeteerNode } from "puppeteer-core"; +import { execSync } from "child_process"; import { existsSync, readdirSync } from "fs"; import { join } from "path"; import { homedir, totalmem } from "os"; @@ -485,7 +486,7 @@ let _cachedVramMb: number | null = null; function probeNvidiaVramMb(): number | null { if (_cachedVramMb !== null) return _cachedVramMb; try { - const { execSync } = require("child_process") as typeof import("child_process"); + // Synchronous, runs once per process (cached). ~50ms on typical systems. const out = execSync("nvidia-smi --query-gpu=memory.total --format=csv,noheader,nounits", { timeout: 3000, encoding: "utf-8", @@ -504,7 +505,7 @@ function probeNvidiaVramMb(): number | null { function getGpuMemBudgetMb(): number { const vram = probeNvidiaVramMb(); - if (vram) return Math.min(vram, 65536); + if (vram) return Math.min(vram, 16384); const total = getTotalMemMb(); if (total < 4096) return 512;