ruvnet/RuView · error · RangeError
maxOutputBytes must be a positive safe integer
Error message
maxOutputBytes must be a positive safe integer
What it means
runProcess() caps captured child output with maxOutputBytes and requires a positive safe integer (>= 1, integral, <= Number.MAX_SAFE_INTEGER). Values of 0, negatives, fractions, NaN, Infinity, or numbers beyond the safe-integer range throw this RangeError before the child spawns.
Source
Thrown at harness/homecore/src/process-runner.js:106
export function runProcess(command, args = [], {
cwd,
input = '',
timeoutMs = 120_000,
signal,
maxOutputBytes = 1_048_576,
env = process.env,
envAllowlist = DEFAULT_ENV_ALLOWLIST,
} = {}) {
if (!command || typeof command !== 'string') throw new TypeError('command must be a non-empty string');
if (!Array.isArray(args) || !args.every((arg) => typeof arg === 'string')) {
throw new TypeError('args must be an array of strings');
}
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1_000 || timeoutMs > 1_800_000) {
throw new RangeError('timeoutMs must be a safe integer between 1000 and 1800000');
}
if (!Number.isSafeInteger(maxOutputBytes) || maxOutputBytes < 1) {
throw new RangeError('maxOutputBytes must be a positive safe integer');
}
const childEnv = scrubEnvironment(env, envAllowlist);
return new Promise((resolve, reject) => {
const child = spawn(command, args, {
cwd,
env: childEnv,
detached: process.platform !== 'win32',
shell: false,
windowsHide: true,
stdio: ['pipe', 'pipe', 'pipe'],
});
const stdout = [];
const stderr = [];
let outputBytes = 0;
let overflow = false;
let timedOut = false;
let settled = false;View on GitHub (pinned to 4685618388)
Solutions
- Pass an explicit positive integer cap such as the default 1_048_576 or 2_097_152
- Validate computed values with Number.isSafeInteger(v) && v >= 1 before the call
- Do not use 0 or Infinity to mean unlimited; choose the largest acceptable cap explicitly
Example fix
// before
await runProcess('cargo', ['test'], { maxOutputBytes: 0 }); // meant unlimited
// after
await runProcess('cargo', ['test'], { maxOutputBytes: 2_097_152 }); Defensive patterns
Strategy: validation
Validate before calling
function normalizeMaxOutputBytes(value, fallback = 1_048_576) {
return Number.isSafeInteger(value) && value >= 1 ? value : fallback;
}
// use: runProcess(cmd, args, { maxOutputBytes: normalizeMaxOutputBytes(cfg.limit) }) Type guard
/** @param {unknown} v @returns {v is number} */
function isValidMaxOutputBytes(v) {
return Number.isSafeInteger(v) && v >= 1;
} Try / catch
try {
await runProcess(cmd, args, { maxOutputBytes });
} catch (error) {
if (error instanceof RangeError && error.message.includes('maxOutputBytes')) {
throw new Error(`maxOutputBytes=${maxOutputBytes} must be a positive safe integer`);
}
throw error;
} Prevention
- Never use 0 or Infinity to request unlimited output — pick an explicit large cap
- Treat any NaN from computed limits as a configuration bug and fall back to a sane default before calling
- Remember the cap exists to bound memory: size it to the largest real output you expect
When it happens
Trigger: {maxOutputBytes: 0} intending 'unlimited', {maxOutputBytes: NaN} from arithmetic on undefined, {maxOutputBytes: 1e21} beyond the safe-integer range, or negative values from subtraction.
Common situations: Using 0 to disable the cap (unsupported), computing the cap from float math or user input, Infinity defaults leaking into options via object spread.
Related errors
- timeoutMs must be a safe integer between 1000 and 1800000
- command must be a non-empty string
- args must be an array of strings
- Unsupported verification profile: ${profile}
- unsupported guidance topic: ${topic}
AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16).
Data as JSON: /api/errors/537cdc3d58d47ce4.
Report an issue: GitHub.