Skip to content

The agent that grows with you

fix(desktop): apply desktop.electron_flags and the renderer heap ceiling at launch again

ethernet55e89768943a
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index bfde00b3348..98a2c218314 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -419,6 +419,7 @@ import {
resolveRemoteRequestHeaders
} from './remote-ws-headers'
import { missingRendererAssets } from './renderer-bundle'
+import { planLaunchSwitches, readDesktopLaunchConfig } from './renderer-heap-flags'
import { loadRendererLoadErrorPage } from './renderer-load-error-page'
import { attachRendererConsoleCapture, formatRendererBoundaryReport } from './renderer-log'
import { fetchRosterSourceData } from './roster-source-fetch'
@@ -805,6 +806,34 @@ const HERMES_HOME: string = resolveDesktopHermesHome({
readWindowsHome: (): string | null => readWindowsUserEnvVar('HERMES_HOME')
})
+// #77311: `desktop.electron_flags` and the renderer heap ceiling
+// (`desktop.renderer_max_old_space_mb`) used to reach Chromium only through
+// the `hermes desktop` launcher's argv, so a packaged app opened from its
+// Start-menu / .desktop entry ran with no `--js-flags` at all. Apply them here
+// from config.yaml, before `ready` — Chromium copies `js-flags` to renderer
+// processes only from the browser's pre-launch command line.
+{
+ let desktopLaunchYaml: string = ''
+
+ try {
+ desktopLaunchYaml = fs.readFileSync(path.join(HERMES_HOME, 'config.yaml'), 'utf8')
+ } catch {
+ void 0 // first run: no config yet → Chromium defaults
+ }
+
+ for (const planned of planLaunchSwitches(readDesktopLaunchConfig(desktopLaunchYaml), process.argv.slice(1))) {
+ if (planned.value === undefined) {
+ app.commandLine.appendSwitch(planned.name)
+ } else {
+ app.commandLine.appendSwitch(planned.name, planned.value)
+ }
+
+ console.log(
+ `[hermes] desktop launch switch from config.yaml: --${planned.name}${planned.value === undefined ? '' : `=${planned.value}`}`
+ )
+ }
+}
+
// ACTIVE_HERMES_ROOT — the canonical mutable Hermes install. Same path
// install.ps1 / install.sh use, so a desktop-only user and a CLI-only user end
// up with identical layouts and can share one install.