From 74f8e5987756e3899fe930b904c35ae22d0718dd Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Wed, 29 Jul 2026 16:15:49 +0500 Subject: [PATCH] fix(desktop): widen probe-budget fix to sibling boot-path probes Follow-up to #73907 (probe timeout 15s + env override + timeout-only retry), widening the same fix to the two sibling sites it missed: - backendSupportsServe's serve --help probe kept a bare execFileSync with its own 15s literal: same cold-Windows Python-startup class (#72632 measured ~10.5s for --version cold), no retry, and a false negative is cached for the process lifetime - silently routing a modern runtime through the legacy dashboard form. Route it through execProbeSync with the shared PROBE_TIMEOUT_MS (honours HERMES_PROBE_TIMEOUT_MS) and the timeout-only retry. - resolveHermesBackend step 4 called unwrapWindowsVenvHermesCommand twice; the second call re-ran the same un-memoized import probe, costing up to another full probe timeout on a hung interpreter for an answer the first call already gave. Drop the redundant re-probe. Part of the #72707 bug class (transient disconnect must not strand a healthy install). --- apps/desktop/electron/backend-probes.ts | 2 ++ apps/desktop/electron/main.ts | 37 +++++++++++++++---------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/apps/desktop/electron/backend-probes.ts b/apps/desktop/electron/backend-probes.ts index 6f5b0b43927..7133342141e 100644 --- a/apps/desktop/electron/backend-probes.ts +++ b/apps/desktop/electron/backend-probes.ts @@ -92,6 +92,7 @@ function execProbeSync( command: string, args: string[], options: { + cwd?: string env?: NodeJS.ProcessEnv stdio: 'ignore' timeout: number @@ -211,6 +212,7 @@ function verifyHermesCli(hermesCommand: string, opts?: { shell?: boolean }) { export { canImportHermesCli, DEFAULT_PROBE_TIMEOUT_MS, + execProbeSync, hermesRuntimeImportProbe, PROBE_TIMEOUT_MS, resolveProbeTimeoutMs, diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts index 80d77d4a34a..b8a5cc78834 100644 --- a/apps/desktop/electron/main.ts +++ b/apps/desktop/electron/main.ts @@ -37,7 +37,7 @@ import { dashboardFallbackArgs, sourceDeclaresServe } from './backend-command' import { createBackendConnectionState } from './backend-connection-state' import { buildDesktopBackendEnv, normalizeHermesHomeRoot } from './backend-env' import { isReauthRequiredError, waitForHermesReady } from './backend-health' -import { canImportHermesCli, shouldTrustHermesOverride, verifyHermesCli } from './backend-probes' +import { canImportHermesCli, execProbeSync, PROBE_TIMEOUT_MS, shouldTrustHermesOverride, verifyHermesCli } from './backend-probes' import { waitForDashboardPortAnnouncement } from './backend-ready' import { shouldLatchBackendStartFailure, shouldLatchRemoteReauthFailure } from './backend-start-failure' import { detectRemoteDisplay, isWindowsBinaryPathInWsl, isWslEnvironment } from './bootstrap-platform' @@ -1886,10 +1886,16 @@ function backendSupportsServe(backend) { if (supported === null) { try { const prefix = backend.args && backend.args[0] === '-m' ? backend.args.slice(0, 2) : [] - execFileSync(backend.command, [...prefix, 'serve', '--help'], { + // Same cold-Windows Python-startup class as the runtime probes + // (#61764/#72632/#72707): `serve --help` imports at least as much as + // `hermes --version` (~10.5s measured cold), and a false negative here + // is cached for the process lifetime, silently routing a modern + // runtime through the legacy `dashboard` form. Share the probe budget + // and its timeout-only retry instead of a thinner local bound. + execProbeSync(backend.command, [...prefix, 'serve', '--help'], { cwd: backend.root || undefined, env: { ...process.env, HERMES_HOME, ...(backend.env || {}) }, - timeout: 15000, + timeout: PROBE_TIMEOUT_MS, stdio: 'ignore', windowsHide: true }) @@ -3879,17 +3885,20 @@ function resolveHermesBackend(backendArgs) { // through to the install-script bootstrap if the optional probe times // out under load; the pinned backend is the only valid runtime there. if (shouldTrustHermesOverride(hermesOverride) || verifyHermesCli(hermesCommand, { shell: shellForProbe })) { - return ( - unwrapWindowsVenvHermesCommand(hermesCommand, backendArgs) || { - label: `existing Hermes CLI at ${hermesCommand}`, - command: hermesCommand, - args: backendArgs, - bootstrap: false, - env: {}, - kind: 'command', - shell: shellForProbe - } - ) + // `unwrapped` above already answered "is this a Windows venv shim?" — + // it was null (not a shim, or its import probe failed). Do NOT re-run + // unwrapWindowsVenvHermesCommand here: the second call repeats the + // same un-memoized import probe, costing up to another full probe + // timeout on the boot path for an answer we already have. + return { + label: `existing Hermes CLI at ${hermesCommand}`, + command: hermesCommand, + args: backendArgs, + bootstrap: false, + env: {}, + kind: 'command', + shell: shellForProbe + } } rememberLog(