stablyai/orca · error · Error

ORCA_PTY_BENCH_PTY_COUNT must be positive, received ${PTY_CO

Error message

ORCA_PTY_BENCH_PTY_COUNT must be positive, received ${PTY_COUNT}

What it means

Thrown by config/scripts/pty-batch-flush-benchmark.mjs at startup when the ORCA_PTY_BENCH_PTY_COUNT environment variable fails the guard `!Number.isInteger(PTY_COUNT) || PTY_COUNT <= 0`. PTY_COUNT drives how many pseudo-terminal slots the PTY batch-flush benchmark simulates (default 24), so a non-positive or non-integer value would make the benchmark loop degenerate. Because Number.parseInt returns NaN for non-numeric input and Number.isInteger(NaN) is false, garbage values trip the same guard as zero or negative ones.

Source

Thrown at config/scripts/pty-batch-flush-benchmark.mjs:21

import v8 from 'node:v8'

const PTY_COUNT = Number.parseInt(process.env.ORCA_PTY_BENCH_PTY_COUNT ?? '24', 10)
const PAYLOAD_CHARS = Number.parseInt(process.env.ORCA_PTY_BENCH_PAYLOAD_CHARS ?? '262144', 10)
const RUNS = Number.parseInt(process.env.ORCA_PTY_BENCH_RUNS ?? '30', 10)
const MEASURE_TIMER_DELAYS = process.env.ORCA_PTY_BENCH_MEASURE_TIMER_DELAYS !== '0'
const INGRESS_CHUNKS = Number.parseInt(process.env.ORCA_PTY_BENCH_INGRESS_CHUNKS ?? '96', 10)
const INGRESS_CHUNK_CHARS = Number.parseInt(process.env.ORCA_PTY_BENCH_INGRESS_CHARS ?? '65536', 10)
const CHUNK_CHARS = 16 * 1024
const MAX_WRITES_PER_SLICE = 2
const RECENT_PTY_OUTPUT_LIMIT = 4096
const MAX_TAIL_LINES = 2000
const MAX_TAIL_CHARS = 256 * 1024
const MAX_TAIL_PARTIAL_CHARS = 4000
const OSC_TITLE_RE = /\x1b\]([012]);([^\x07\x1b]*?)(?:\x07|\x1b\\)/g
const URL_CANDIDATE_PATTERN = /\bhttps?:\/\/[^\s<>"'`]+/gi

if (!Number.isInteger(PTY_COUNT) || PTY_COUNT <= 0) {
  throw new Error(`ORCA_PTY_BENCH_PTY_COUNT must be positive, received ${PTY_COUNT}`)
}
if (!Number.isInteger(PAYLOAD_CHARS) || PAYLOAD_CHARS <= 0) {
  throw new Error(`ORCA_PTY_BENCH_PAYLOAD_CHARS must be positive, received ${PAYLOAD_CHARS}`)
}
if (!Number.isInteger(RUNS) || RUNS <= 0) {
  throw new Error(`ORCA_PTY_BENCH_RUNS must be positive, received ${RUNS}`)
}
if (!Number.isInteger(INGRESS_CHUNKS) || INGRESS_CHUNKS <= 0) {
  throw new Error(`ORCA_PTY_BENCH_INGRESS_CHUNKS must be positive, received ${INGRESS_CHUNKS}`)
}
if (!Number.isInteger(INGRESS_CHUNK_CHARS) || INGRESS_CHUNK_CHARS <= 0) {
  throw new Error(`ORCA_PTY_BENCH_INGRESS_CHARS must be positive, received ${INGRESS_CHUNK_CHARS}`)
}

function makePendingData() {
  const pending = new Map()
  for (let index = 0; index < PTY_COUNT; index++) {
    pending.set(`pty-${index}`, `${index}:`.padEnd(PAYLOAD_CHARS, 'x'))

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Unset ORCA_PTY_BENCH_PTY_COUNT to fall back to the default of 24, or set it to a positive integer.
  2. If scripting, default the value explicitly: `PTY_COUNT=${ORCA_PTY_BENCH_PTY_COUNT:-24}` before invoking.
  3. Validate the env in your wrapper before running: reject non-integer or non-positive values with a clear message.

Example fix

// before
ORCA_PTY_BENCH_PTY_COUNT=0 node config/scripts/pty-batch-flush-benchmark.mjs

// after
ORCA_PTY_BENCH_PTY_COUNT=24 node config/scripts/pty-batch-flush-benchmark.mjs
Defensive patterns

Strategy: validation

Validate before calling

// Validate before running the benchmark script
const raw = process.env.ORCA_PTY_BENCH_PTY_COUNT
if (raw !== undefined && (!Number.isInteger(Number(raw)) || Number(raw) <= 0)) {
  throw new Error(`Refusing to run: ORCA_PTY_BENCH_PTY_COUNT='${raw}' must be a positive integer`)
}

Type guard

function isPositiveIntEnv(value) {
  if (value === undefined) return true // default applies
  const n = Number(value)
  return Number.isInteger(n) && n > 0
}

Prevention

When it happens

Trigger: Run `node config/scripts/pty-batch-flush-benchmark.mjs` with ORCA_PTY_BENCH_PTY_COUNT set to `0`, `-1`, `2.5` (parseFloat would differ but parseInt floors), an empty string, or any non-numeric token like `abc`. The module-level parse at line 5 runs unconditionally before any benchmark logic, so the throw happens before main() executes.

Common situations: A developer shells out with a typo'd env var (e.g. `ORCA_PTY_BENCH_PTY_COUNT=zero`), copies a CI snippet that leaves the value blank (`PTY_COUNT=`), or reuses a harness that previously set the count to 0 to skip a run. Exporting the var via a script that conditionally sets it to an empty string also hits this.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/ac44c87b5e3b08ae. Report an issue: GitHub.