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 <paovalletta@hotmail.it>
Co-authored-by: Orca Worker <orca-worker@localhost>
This commit is contained in:
OrcaWin
2026-10-11 20:27:11 -07:00
committed by GitHub
co-authored by Paolo Orca Worker
parent b9d1b958ee
commit bb12a8a1e4
3 changed files with 19 additions and 11 deletions
@@ -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.
@@ -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) {
@@ -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