stablyai/orca · error

${name} must be a positive integer, received ${value}

Error message

${name} must be a positive integer, received ${value}

What it means

Thrown by the advertised-url-watcher benchmark when one of ORCA_ADVERTISED_URL_BENCH_ITERATIONS / _ROUNDS / _WARMUP is not a safe positive integer. Number(env) is used, so non-numeric strings become NaN, decimals become floats, and oversized values exceed Number.isSafeInteger — each is rejected because the timing loops need integer counts.

Source

Thrown at config/scripts/advertised-url-watcher-benchmark.mjs:59

  }
}

const { AdvertisedUrlWatcher, extractUrlCandidates, stripTerminalControls } = await import(
  new URL('../../src/main/ports/advertised-url-watcher.ts', import.meta.url).href
)

const BUFFER_LIMIT = 4096
const ITERATIONS = Number(process.env.ORCA_ADVERTISED_URL_BENCH_ITERATIONS ?? '10000')
const ROUNDS = Number(process.env.ORCA_ADVERTISED_URL_BENCH_ROUNDS ?? '12')
const WARMUP = Number(process.env.ORCA_ADVERTISED_URL_BENCH_WARMUP ?? '1000')

for (const [name, value] of [
  ['ORCA_ADVERTISED_URL_BENCH_ITERATIONS', ITERATIONS],
  ['ORCA_ADVERTISED_URL_BENCH_ROUNDS', ROUNDS],
  ['ORCA_ADVERTISED_URL_BENCH_WARMUP', WARMUP]
]) {
  if (!Number.isSafeInteger(value) || value <= 0) {
    throw new Error(`${name} must be a positive integer, received ${value}`)
  }
}
if (ROUNDS % 2 !== 0) {
  throw new Error('ORCA_ADVERTISED_URL_BENCH_ROUNDS must be even')
}

class BeforePtyBuffer {
  raw = ''

  ingest(chunk) {
    const chunkHasLineBreak = chunk.includes('\n') || chunk.includes('\r')
    this.raw += chunk
    if (this.raw.length > BUFFER_LIMIT) {
      this.raw = this.raw.slice(-BUFFER_LIMIT)
    }
    if (!chunkHasLineBreak) {
      return ''
    }

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Set each env var to a positive integer within Number.MAX_SAFE_INTEGER, e.g. ORCA_ADVERTISED_URL_BENCH_ITERATIONS=10000 ORCA_ADVERTISED_URL_BENCH_ROUNDS=12 ORCA_ADVERTISED_URL_BENCH_WARMUP=1000.
  2. If unset, the defaults (10000/12/1000) are correct — remove the override entirely.
  3. Validate the env in the workflow with a regex (^[1-9][0-9]*$) before invoking the benchmark.
  4. For very large stress runs, scale ROUNDS rather than ITERATIONS to stay within safe-integer range.

Example fix

// before
// ORCA_ADVERTISED_URL_BENCH_ITERATIONS=1e21 node config/scripts/advertised-url-watcher-benchmark.mjs
// -> 'ORCA_ADVERTISED_URL_BENCH_ITERATIONS must be a positive integer, received 1e+21'

// after
// ORCA_ADVERTISED_URL_BENCH_ITERATIONS=20000 node config/scripts/advertised-url-watcher-benchmark.mjs
Defensive patterns

Strategy: validation

Validate before calling

function readPositiveIntEnv(name, fallback) {
  const raw = process.env[name]
  if (raw == null || raw === '') return fallback
  const n = Number(raw)
  if (!Number.isSafeInteger(n) || n <= 0) {
    throw new Error(`${name} must be a positive safe integer, got '${raw}'`)
  }
  return n
}
// const ITERATIONS = readPositiveIntEnv('ORCA_ADVERTISED_URL_BENCH_ITERATIONS', 10000)

Type guard

function isPositiveSafeInteger(value) {
  return Number.isSafeInteger(value) && value > 0
}

Prevention

When it happens

Trigger: Setting ORCA_ADVERTISED_URL_BENCH_ITERATIONS=10000.5 (float), =1e21 (exceeds MAX_SAFE_INTEGER), =abc (NaN), =0 or negative, or unsetting and overriding with an empty string.

Common situations: Operator typo in a CI workflow env block; copying a value from another benchmark without adjusting precision; attempting a stress run with an absurd iteration count.

Related errors


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