stablyai/orca · error

ORCA_ADVERTISED_URL_BENCH_ROUNDS must be even

Error message

ORCA_ADVERTISED_URL_BENCH_ROUNDS must be even

What it means

Thrown by the advertised-url-watcher benchmark when ORCA_ADVERTISED_URL_BENCH_ROUNDS is odd. The benchmark alternates which arm leads each round to neutralize within-round drift (see measure()), and the median computation requires an even count; an odd value would skew the median and undermine the comparison's fairness.

Source

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

  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 ''
    }
    const lastNewline = lastLineBreak(this.raw)
    if (lastNewline === -1) {
      return ''
    }

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Use an even value: ORCA_ADVERTISED_URL_BENCH_ROUNDS=12 (default) or 6, 10, 20.
  2. For a quick smoke run, drop to 2 rounds (still even) rather than 1 or 3.
  3. Update the workflow's documented default if a different even number is desired.
  4. If you genuinely need odd rounds, also update the median() helper in the benchmark to handle odd-length samples.

Example fix

// before
// ORCA_ADVERTISED_URL_BENCH_ROUNDS=7 node config/scripts/advertised-url-watcher-benchmark.mjs
// -> 'ORCA_ADVERTISED_URL_BENCH_ROUNDS must be even'

// after
// ORCA_ADVERTISED_URL_BENCH_ROUNDS=6 node config/scripts/advertised-url-watcher-benchmark.mjs
Defensive patterns

Strategy: validation

Validate before calling

function readEvenPositiveIntEnv(name, fallback) {
  const raw = process.env[name]
  const n = raw == null || raw === '' ? fallback : Number(raw)
  if (!Number.isSafeInteger(n) || n <= 0) throw new Error(`${name} must be a positive integer`)
  if (n % 2 !== 0) throw new Error(`${name} must be even`)
  return n
}
// const ROUNDS = readEvenPositiveIntEnv('ORCA_ADVERTISED_URL_BENCH_ROUNDS', 12)

Prevention

When it happens

Trigger: Operator sets ORCA_ADVERTISED_URL_BENCH_ROUNDS=5 (or any odd number); the default of 12 was overridden with an odd value.

Common situations: Operator picks a 'nicer' round count (5, 7, 10) without reading the parity requirement; CI workflow hardcoded an odd default; reducing rounds for a quick smoke run landed on an odd number.

Related errors


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