From bb12a8a1e456bd57012c18def5414cce7bcf2613 Mon Sep 17 00:00:00 2001 From: OrcaWin Date: Sun, 11 Oct 2026 20:27:11 -0700 Subject: [PATCH] fix(bench): load benchmark sources as file URLs so they run on Windows (#27621) * fix(bench): resolve dynamically imported sources as file URLs `await import(path.join(ROOT, '...ts'))` hands Node a bare Windows path (`C:\...`), which the ESM loader rejects as an unsupported URL scheme ("Received protocol 'c:'"). The two benchmarks that load production modules this way crashed on Windows before running a single scenario, while working on macOS and Linux where an absolute path is a valid specifier. Wrap each computed specifier in `pathToFileURL(...).href`, the form the other benchmark scripts already use for the same purpose. Verified on Windows: bench:session-write-hot-path and bench:agent-inspection-cadence now run and print their measurement tables. The fish mode-2031 trace capture resolves its import too, but its harness targets macOS/Linux shells and cannot complete on Windows. Fixes #25235 * style(bench): format the session-write benchmark's file-URL import --------- Co-authored-by: Paolo Co-authored-by: Orca Worker --- .../agent-inspection-cadence-batching-benchmark.mjs | 12 ++++++++---- config/scripts/session-write-hot-path-benchmark.mjs | 13 +++++++------ .../capture-fish-mode2031-trace.mjs | 5 ++++- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/config/scripts/agent-inspection-cadence-batching-benchmark.mjs b/config/scripts/agent-inspection-cadence-batching-benchmark.mjs index 128627676c4..bdcd9c62fd0 100644 --- a/config/scripts/agent-inspection-cadence-batching-benchmark.mjs +++ b/config/scripts/agent-inspection-cadence-batching-benchmark.mjs @@ -12,7 +12,7 @@ import fs from 'node:fs' import nodeModule from 'node:module' import path from 'node:path' import process from 'node:process' -import { fileURLToPath } from 'node:url' +import { fileURLToPath, pathToFileURL } from 'node:url' if (!process.execArgv.includes('--experimental-transform-types')) { const result = spawnSync( @@ -51,13 +51,17 @@ for (const paneCount of PANE_COUNTS) { } const { nextCadenceInspectionDelayMs } = await import( - path.join(ROOT, 'src/renderer/src/components/terminal-pane/agent-completion-poll-interval.ts') + pathToFileURL( + path.join(ROOT, 'src/renderer/src/components/terminal-pane/agent-completion-poll-interval.ts') + ).href ) const { POLL_TIER_INTERVAL_MS } = await import( - path.join(ROOT, 'src/renderer/src/components/terminal-pane/agent-completion-poll-cadence.ts') + pathToFileURL( + path.join(ROOT, 'src/renderer/src/components/terminal-pane/agent-completion-poll-cadence.ts') + ).href ) const { PROCESS_TABLE_SNAPSHOT_MAX_STALENESS_MS } = await import( - path.join(ROOT, 'src/shared/process-table-snapshot-reader.ts') + pathToFileURL(path.join(ROOT, 'src/shared/process-table-snapshot-reader.ts')).href ) // Pre-change: independent ±10% jitter per pane, re-rolled on every reschedule. diff --git a/config/scripts/session-write-hot-path-benchmark.mjs b/config/scripts/session-write-hot-path-benchmark.mjs index 361e7eb7098..e76ec607f0b 100644 --- a/config/scripts/session-write-hot-path-benchmark.mjs +++ b/config/scripts/session-write-hot-path-benchmark.mjs @@ -15,7 +15,7 @@ import fs from 'node:fs' import nodeModule from 'node:module' import path from 'node:path' import process from 'node:process' -import { fileURLToPath } from 'node:url' +import { fileURLToPath, pathToFileURL } from 'node:url' if (!process.execArgv.includes('--experimental-transform-types')) { const result = spawnSync( @@ -55,19 +55,20 @@ for (const [name, value] of [ } const { capTerminalScrollbackSessionBuffer } = await import( - path.join(ROOT, 'src/shared/workspace-session-terminal-buffers.ts') + pathToFileURL(path.join(ROOT, 'src/shared/workspace-session-terminal-buffers.ts')).href ) const { TERMINAL_SCROLLBACK_SESSION_BUFFER_BYTE_LIMIT } = await import( - path.join(ROOT, 'src/shared/terminal-scrollback-limits.ts') + pathToFileURL(path.join(ROOT, 'src/shared/terminal-scrollback-limits.ts')).href ) const { remapAcknowledgedAgentPaneKeys } = await import( - path.join(ROOT, 'src/main/persistence/restoring-sessions/pane-key-remapping.ts') + pathToFileURL(path.join(ROOT, 'src/main/persistence/restoring-sessions/pane-key-remapping.ts')) + .href ) const { clampUtf8TextTail, measureUtf8ByteLength } = await import( - path.join(ROOT, 'src/shared/utf8-byte-limits.ts') + pathToFileURL(path.join(ROOT, 'src/shared/utf8-byte-limits.ts')).href ) const { isTerminalLeafId, makePaneKey, parsePaneKey } = await import( - path.join(ROOT, 'src/shared/stable-pane-id.ts') + pathToFileURL(path.join(ROOT, 'src/shared/stable-pane-id.ts')).href ) function median(samples) { diff --git a/tests/tools/fish-mode2031-repro/capture-fish-mode2031-trace.mjs b/tests/tools/fish-mode2031-repro/capture-fish-mode2031-trace.mjs index 1b2cbcae38c..d3bb775cf61 100644 --- a/tests/tools/fish-mode2031-repro/capture-fish-mode2031-trace.mjs +++ b/tests/tools/fish-mode2031-repro/capture-fish-mode2031-trace.mjs @@ -33,13 +33,16 @@ import { mkdtempSync, writeFileSync, mkdirSync, rmSync } from 'node:fs' import { tmpdir } from 'node:os' import path from 'node:path' import { createRequire } from 'node:module' +import { pathToFileURL } from 'node:url' const require = createRequire(import.meta.url) const REPO_ROOT = path.resolve(import.meta.dirname, '../../..') const pty = require(path.join(REPO_ROOT, 'node_modules/node-pty')) const { INITIAL_MODE_2031_REPLY_SCAN_STATE, mode2031SequenceFor, scanMode2031ReplyDecision } = - await import(path.join(REPO_ROOT, 'src/shared/terminal-color-scheme-protocol.ts')) + await import( + pathToFileURL(path.join(REPO_ROOT, 'src/shared/terminal-color-scheme-protocol.ts')).href + ) // ---------------------------------------------------------------- args