{"record":{"id":"fbf8c40b05d03b06","repo":"stablyai/orca","slug":"name-must-be-a-positive-integer-received-val-fbf8c4","errorCode":null,"errorMessage":"${name} must be a positive integer, received ${value}","messagePattern":"(.+?) must be a positive integer, received (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/hibernation-output-epoch-leak-benchmark.mjs","lineNumber":22,"sourceCode":"//\n// recordAgentHibernationPaneOutput() adds one entry per pane (keyed by\n// `tabId:leafId`, leafId a fresh UUID each open) on every PTY output chunk.\n// Before the fix nothing purged those entries on permanent pane/worktree close,\n// so the module-level Map grew for the renderer's whole lifetime. This script\n// simulates N open→emit→close cycles and reports retained Map size with the\n// purge disabled vs enabled.\nimport { performance } from 'node:perf_hooks'\nimport v8 from 'node:v8'\n\nconst CYCLES = Number.parseInt(process.env.ORCA_EPOCH_BENCH_CYCLES ?? '20000', 10)\nconst PANES_PER_TAB = Number.parseInt(process.env.ORCA_EPOCH_BENCH_PANES ?? '2', 10)\n\nfor (const [name, value] of [\n  ['ORCA_EPOCH_BENCH_CYCLES', CYCLES],\n  ['ORCA_EPOCH_BENCH_PANES', PANES_PER_TAB]\n]) {\n  if (!Number.isInteger(value) || value <= 0) {\n    throw new Error(`${name} must be a positive integer, received ${value}`)\n  }\n}\n\n// Mirror of the module under test (agent-hibernation-output-activity.ts): a\n// module-level Map of paneKey -> epoch, plus the tab-scoped purge the fix adds.\nfunction makeActivity() {\n  const outputEpochByPaneKey = new Map()\n  return {\n    map: outputEpochByPaneKey,\n    record(paneKey) {\n      outputEpochByPaneKey.set(paneKey, (outputEpochByPaneKey.get(paneKey) ?? 0) + 1)\n    },\n    forgetTab(tabId) {\n      const prefix = `${tabId}:`\n      for (const paneKey of outputEpochByPaneKey.keys()) {\n        if (paneKey.startsWith(prefix)) {\n          outputEpochByPaneKey.delete(paneKey)\n        }","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/hibernation-output-epoch-leak-benchmark.mjs#L4-L40","documentation":"Thrown by the hibernation-output-epoch-leak benchmark when ORCA_EPOCH_BENCH_CYCLES or ORCA_EPOCH_BENCH_PANES parses (via Number.parseInt) to a non-integer or a value <= 0. These env vars configure the simulated open→emit→close cycle count and panes-per-tab for the heap-leak benchmark.","triggerScenarios":"Setting ORCA_EPOCH_BENCH_CYCLES to a non-numeric string ('abc'), zero, a negative number, a float string that parseInt floors to a bad value, or leaving it set to an empty/garbage value from a prior run.","commonSituations":"CI env var misconfiguration, typos, passing a float, or inheriting a stale/garbage value from the environment.","solutions":["Set both env vars to positive integers, or omit them to use the defaults (20000 cycles, 2 panes).","Validate the env in the CI workflow before invoking the script."],"exampleFix":"# before\nORCA_EPOCH_BENCH_CYCLES=abc ORCA_EPOCH_BENCH_PANES=0 node config/scripts/hibernation-output-epoch-leak-benchmark.mjs\n# after\nORCA_EPOCH_BENCH_CYCLES=50000 ORCA_EPOCH_BENCH_PANES=4 node config/scripts/hibernation-output-epoch-leak-benchmark.mjs","handlingStrategy":"validation","validationCode":"function positiveIntEnv(name: string, fallback: string): number {\n  const v = Number.parseInt(process.env[name] ?? fallback, 10)\n  if (!Number.isInteger(v) || v <= 0) throw new Error(`${name} must be a positive integer, got ${process.env[name]}`)\n  return v\n}\nconst CYCLES = positiveIntEnv('ORCA_EPOCH_BENCH_CYCLES', '20000')\nconst PANES_PER_TAB = positiveIntEnv('ORCA_EPOCH_BENCH_PANES', '2')","typeGuard":"const isPositiveInteger = (v: unknown): v is number => typeof v === 'number' && Number.isInteger(v) && v > 0","tryCatchPattern":null,"preventionTips":["Omit the env vars to use safe defaults rather than risk a bad override.","Validate env vars in CI before invoking the benchmark."],"tags":["benchmark","environment","validation","numeric"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}