mastra-ai/mastra · error

${name} must be greater than zero.

Error message

${name} must be greater than zero.

What it means

The optional numeric worker options inputLimitBytes, startupTimeoutMs, executionTimeoutMs, and terminationGraceMs must each be a finite number greater than zero when provided. This check runs inside validateOptions before any sandbox interaction, using the option name in the message.

Source

Thrown at deployers/sandbox/src/worker.ts:183

  }
  validateExecutionId(options.executionId);
  if (!options.command || /[\0\r\n]/.test(options.command)) {
    throw new Error('Worker command must be a non-empty executable path.');
  }
  if (options.args?.some(arg => arg.includes('\0'))) throw new Error('Worker arguments must not contain NUL bytes.');
  for (const key of Object.keys(options.env ?? {})) {
    if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) throw new Error(`Invalid worker environment variable name: ${key}`);
  }
  validateRelativePath(options.workingDirectory ?? '.', 'workingDirectory');
  validateInput(options.input);
  for (const [name, value] of [
    ['inputLimitBytes', options.inputLimitBytes],
    ['startupTimeoutMs', options.startupTimeoutMs],
    ['executionTimeoutMs', options.executionTimeoutMs],
    ['terminationGraceMs', options.terminationGraceMs],
  ] as const) {
    if (value !== undefined && (!Number.isFinite(value) || value <= 0))
      throw new Error(`${name} must be greater than zero.`);
  }
  const resourceLimits = options.resourceLimits;
  if (resourceLimits) {
    const knownLimits = new Set(['cpuTimeSeconds', 'addressSpaceBytes', 'fileSizeBytes', 'openFiles']);
    for (const name of Object.keys(resourceLimits)) {
      if (!knownLimits.has(name)) throw new Error(`Unknown worker resource limit: ${name}.`);
    }
    for (const [name, value] of [
      ['cpuTimeSeconds', resourceLimits.cpuTimeSeconds],
      ['addressSpaceBytes', resourceLimits.addressSpaceBytes],
      ['fileSizeBytes', resourceLimits.fileSizeBytes],
      ['openFiles', resourceLimits.openFiles],
    ] as const) {
      if (value !== undefined && (!Number.isSafeInteger(value) || value <= 0)) {
        throw new Error(`Worker resourceLimits.${name} must be a positive safe integer.`);
      }
    }
  }

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Provide positive finite millisecond/byte values, or omit the option entirely (undefined is valid).
  2. Guard each value: if (v !== undefined && (!Number.isFinite(v) || v <= 0)) fix the config source.
  3. Fix parsing — coerce strings with Number() and validate Number.isFinite before constructing options.

Example fix

// before
await deployWorkerToSandbox({ sandbox, command: 'node', startupTimeoutMs: 0 });
// after
await deployWorkerToSandbox({ sandbox, command: 'node', startupTimeoutMs: 30000 });
Defensive patterns

Strategy: validation

Validate before calling

const numericChecks = { inputLimitBytes: opts.inputLimitBytes, startupTimeoutMs: opts.startupTimeoutMs, executionTimeoutMs: opts.executionTimeoutMs, terminationGraceMs: opts.terminationGraceMs };
for (const [name, v] of Object.entries(numericChecks)) {
  if (v !== undefined && (!Number.isFinite(v) || v <= 0)) throw new Error(`${name} must be a positive finite number`);
}

Type guard

const isPositiveFinite = (v: unknown): v is number =>
  typeof v === 'number' && Number.isFinite(v) && v > 0;

Prevention

When it happens

Trigger: Passing any of these four options as 0, negative, NaN, or Infinity to deployWorkerToSandbox.

Common situations: Disabling a timeout by setting it to 0 (instead of omitting it); string values from env/config that were never converted (NaN); computing durations with buggy arithmetic producing negative or infinite values.

Understand the failure class

Background: Invalid option value errors: "must be one of", "is not a valid", and "only allows" failures explained — this error's family across 23 libraries.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/08459da0e513b8a6. Report an issue: GitHub.