stablyai/orca · error · Error

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

Error message

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

What it means

Startup guard in the MJPEG frame parser allocation benchmark. Identical pattern to the TOC benchmark: Number.parseInt's ORCA_MJPEG_BENCH_FPS, _SECONDS, _FRAME_BYTES with default fallbacks and rejects non-integer or <=0 values, naming the bad var and value.

Source

Thrown at config/scripts/mjpeg-frame-parser-alloc-benchmark.mjs:37

// implementation calls trackedCopy() wherever it would allocate a copy, so the
// reported "bytes copied" is exact and independent of GC timing.
let copiedBytes = 0
function trackedCopy(buf) {
  copiedBytes += buf.length
  return Buffer.from(buf)
}

const FPS = Number.parseInt(process.env.ORCA_MJPEG_BENCH_FPS ?? '30', 10)
const SECONDS = Number.parseInt(process.env.ORCA_MJPEG_BENCH_SECONDS ?? '30', 10)
const FRAME_BYTES = Number.parseInt(process.env.ORCA_MJPEG_BENCH_FRAME_BYTES ?? '184320', 10) // ~180 KiB

for (const [name, value] of [
  ['ORCA_MJPEG_BENCH_FPS', FPS],
  ['ORCA_MJPEG_BENCH_SECONDS', SECONDS],
  ['ORCA_MJPEG_BENCH_FRAME_BYTES', FRAME_BYTES]
]) {
  if (!Number.isInteger(value) || value <= 0) {
    throw new Error(`${name} must be a positive integer, received ${value}`)
  }
}

const JPEG_START = Buffer.from([0xff, 0xd8])
const JPEG_END = Buffer.from([0xff, 0xd9])

function makeFrame(seed) {
  const body = Buffer.alloc(FRAME_BYTES - 4)
  // Avoid an accidental 0xff 0xd9 inside the body so the frame boundary is clean.
  body.fill(seed % 251 || 1)
  return Buffer.concat([JPEG_START, body, JPEG_END])
}

// --- old implementation: copy chunk + copy every frame -----------------------
function extractOld(pending, chunk, maxPendingBytes = 2 * 1024 * 1024) {
  let cursor = pending.length > 0 ? Buffer.concat([pending, chunk]) : trackedCopy(chunk)
  const frames = []
  while (cursor.length > 0) {

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Unset the offending var to fall back to 30/30/184320
  2. Set a positive integer: ORCA_MJPEG_BENCH_FRAME_BYTES=184320 node mjpeg-frame-parser-alloc-benchmark.mjs
  3. Inspect the exported value byte-for-byte: printf '%s' "$ORCA_MJPEG_BENCH_FPS" | od -c
  4. Validate in the wrapping script with ^[1-9][0-9]*$ before exporting

Example fix

# before
ORCA_MJPEG_BENCH_FPS=0 node config/scripts/mjpeg-frame-parser-alloc-benchmark.mjs

# after
node config/scripts/mjpeg-frame-parser-alloc-benchmark.mjs
Defensive patterns

Strategy: validation

Validate before calling

function positiveIntEnv(name, fallback) {
  const raw = process.env[name]
  if (raw === undefined) return fallback
  if (!/^[1-9][0-9]*$/.test(raw)) {
    throw new Error(`${name} must be a positive integer, received ${raw}`)
  }
  return Number.parseInt(raw, 10)
}

Type guard

function isPositiveInt(v) {
  return Number.isInteger(v) && v > 0
}

Prevention

When it happens

Trigger: Any of the three ORCA_MJPEG_BENCH_* env vars set to a non-numeric, empty, zero, or negative value.

Common situations: CI matrix exporting the var with a typo; inheriting a frame size tuned for a different resolution that was set to 0; quoting artifacts leaving an empty string.

Related errors


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