{"record":{"id":"7155447cedb1104c","repo":"stablyai/orca","slug":"orca-pty-bench-runs-must-be-positive-received-r","errorCode":null,"errorMessage":"ORCA_PTY_BENCH_RUNS must be positive, received ${RUNS}","messagePattern":"ORCA_PTY_BENCH_RUNS must be positive, received (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/pty-batch-flush-benchmark.mjs","lineNumber":27,"sourceCode":"const INGRESS_CHUNKS = Number.parseInt(process.env.ORCA_PTY_BENCH_INGRESS_CHUNKS ?? '96', 10)\nconst INGRESS_CHUNK_CHARS = Number.parseInt(process.env.ORCA_PTY_BENCH_INGRESS_CHARS ?? '65536', 10)\nconst CHUNK_CHARS = 16 * 1024\nconst MAX_WRITES_PER_SLICE = 2\nconst RECENT_PTY_OUTPUT_LIMIT = 4096\nconst MAX_TAIL_LINES = 2000\nconst MAX_TAIL_CHARS = 256 * 1024\nconst MAX_TAIL_PARTIAL_CHARS = 4000\nconst OSC_TITLE_RE = /\\x1b\\]([012]);([^\\x07\\x1b]*?)(?:\\x07|\\x1b\\\\)/g\nconst URL_CANDIDATE_PATTERN = /\\bhttps?:\\/\\/[^\\s<>\"'`]+/gi\n\nif (!Number.isInteger(PTY_COUNT) || PTY_COUNT <= 0) {\n  throw new Error(`ORCA_PTY_BENCH_PTY_COUNT must be positive, received ${PTY_COUNT}`)\n}\nif (!Number.isInteger(PAYLOAD_CHARS) || PAYLOAD_CHARS <= 0) {\n  throw new Error(`ORCA_PTY_BENCH_PAYLOAD_CHARS must be positive, received ${PAYLOAD_CHARS}`)\n}\nif (!Number.isInteger(RUNS) || RUNS <= 0) {\n  throw new Error(`ORCA_PTY_BENCH_RUNS must be positive, received ${RUNS}`)\n}\nif (!Number.isInteger(INGRESS_CHUNKS) || INGRESS_CHUNKS <= 0) {\n  throw new Error(`ORCA_PTY_BENCH_INGRESS_CHUNKS must be positive, received ${INGRESS_CHUNKS}`)\n}\nif (!Number.isInteger(INGRESS_CHUNK_CHARS) || INGRESS_CHUNK_CHARS <= 0) {\n  throw new Error(`ORCA_PTY_BENCH_INGRESS_CHARS must be positive, received ${INGRESS_CHUNK_CHARS}`)\n}\n\nfunction makePendingData() {\n  const pending = new Map()\n  for (let index = 0; index < PTY_COUNT; index++) {\n    pending.set(`pty-${index}`, `${index}:`.padEnd(PAYLOAD_CHARS, 'x'))\n  }\n  return pending\n}\n\nfunction simulateWebContentsSend(id, data) {\n  return v8.serialize({ channel: 'pty:data', payload: { id, data } }).byteLength","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/pty-batch-flush-benchmark.mjs#L9-L45","documentation":"Thrown by config/scripts/pty-batch-flush-benchmark.mjs when ORCA_PTY_BENCH_RUNS fails `!Number.isInteger(RUNS) || RUNS <= 0`. RUNS (default 30) is the number of measurement iterations the benchmark averages over; a non-positive value would make the timing loop produce no samples. Parsed at module load from the env, so the guard at line 26-27 fires immediately on bad input.","triggerScenarios":"Run the benchmark with ORCA_PTY_BENCH_RUNS set to `0`, `-5`, an empty string, or a non-numeric token. parseInt at line 7 yields NaN for non-numeric input and the guard at line 26 throws.","commonSituations":"A developer sets RUNS=0 intending to 'dry-run' the benchmark (there is no dry-run mode), or a smoke-test wrapper sets RUNS to an empty value. Setting RUNS to a float like `1.5` actually passes (parseInt floors to 1), but `1.5px` style garbage fails.","solutions":["Set ORCA_PTY_BENCH_RUNS to a positive integer; for quick smoke runs use a small value like 3.","Unset it to accept the default of 30.","Validate in your wrapper that the value parses to a positive integer before invoking."],"exampleFix":"// before\nORCA_PTY_BENCH_RUNS=0 node config/scripts/pty-batch-flush-benchmark.mjs\n\n// after\nORCA_PTY_BENCH_RUNS=3 node config/scripts/pty-batch-flush-benchmark.mjs","handlingStrategy":"validation","validationCode":"const raw = process.env.ORCA_PTY_BENCH_RUNS\nif (raw !== undefined && (!Number.isInteger(Number(raw)) || Number(raw) <= 0)) {\n  throw new Error(`ORCA_PTY_BENCH_RUNS='${raw}' must be a positive integer`)\n}","typeGuard":"function isPositiveInt(value) {\n  const n = Number(value)\n  return Number.isInteger(n) && n > 0\n}","tryCatchPattern":null,"preventionTips":["For smoke runs use a small positive integer (e.g. 3) instead of 0.","Keep RUNS >= 10 for stable averages; smaller values increase noise.","Validate benchmark env vars in one shared preflight helper."],"tags":["benchmark","env","config","pty","validation"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}