mastra-ai/mastra · error
Worker input exceeds inputLimitBytes (${data.byteLength} > $
Error message
Worker input exceeds inputLimitBytes (${data.byteLength} > ${config.inputLimitBytes}). What it means
stageInput uploads worker input into the sandbox but enforces a configured maximum input size (config.inputLimitBytes). If the serialized input buffer is larger than that limit, the library throws before any upload, since oversized payloads could exhaust sandbox memory/disk or break the transport.
Source
Thrown at deployers/sandbox/src/worker.ts:428
return {
...execution(config, executionId, sandboxId, expiresAt),
relaunch: async options => {
if (options.executionId === executionId) throw new Error('Relaunch requires a new executionId.');
validateInput(options.input);
return createExecution(config, options.executionId, options.input);
},
};
}
async function stageInput(
config: WorkerConfig,
paths: ReturnType<typeof executionPaths>,
input?: SandboxWorkerInput,
): Promise<string | undefined> {
if (!input) return undefined;
const data = typeof input.data === 'string' ? Buffer.from(input.data) : Buffer.from(input.data);
if (data.byteLength > config.inputLimitBytes) {
throw new Error(`Worker input exceeds inputLimitBytes (${data.byteLength} > ${config.inputLimitBytes}).`);
}
const path = input.type === 'stdin' ? paths.stdin : posix.resolve(config.remoteDir, input.path);
await uploadFile(config.sandbox, path, data);
await runInSandbox(config.sandbox, `chmod 600 ${shellQuote(path)}`);
return input.type === 'stdin' ? path : undefined;
}
function buildExecutionScript(
config: WorkerConfig,
paths: ReturnType<typeof executionPaths>,
stdinPath?: string,
): string {
const cwd = posix.resolve(config.remoteDir, config.workingDirectory);
const envPrefix = Object.entries(config.env)
.map(([key, value]) => `${key}=${shellQuote(value)}`)
.join(' ');
const executable = [shellQuote(config.command), ...config.args.map(shellQuote)].join(' ');
const target = `${envPrefix ? `env ${envPrefix} ` : ''}${executable}`;View on GitHub (pinned to 75dd419e61)
Solutions
- Increase config.inputLimitBytes to accommodate your payload size.
- Split the input into chunks and pass a reference (e.g. an object-store key or path) instead of inlining the data.
- Compress the payload before staging and decompress inside the worker.
- Trim the input to only the data the worker actually needs.
Example fix
// before
await worker.run({ input: { type: 'stdin', data: bigJsonString } });
// after
if (Buffer.byteLength(bigJsonString) > inputLimitBytes) {
await uploadToStore(key, bigJsonString);
await worker.run({ input: { type: 'stdin', data: JSON.stringify({ ref: key }) } });
} Defensive patterns
Strategy: validation
Validate before calling
function assertInputWithinLimit(input, inputLimitBytes) {
const bytes = Buffer.byteLength(typeof input === 'string' ? input : input.data);
if (bytes > inputLimitBytes) throw new Error(`input ${bytes}B exceeds limit ${inputLimitBytes}B`);
} Type guard
function inputFitsLimit(input, limit) {
if (!input) return true;
const data = input.data;
const size = typeof data === 'string' ? Buffer.byteLength(data) : data?.byteLength ?? 0;
return size <= limit;
} Try / catch
try {
await worker.run({ input });
} catch (e) {
if (/exceeds inputLimitBytes/.test(e.message)) {
// offload to external storage and pass a reference instead
} else throw e;
} Prevention
- Check input byte size against inputLimitBytes before every call.
- Prefer passing storage references over inlining large blobs.
- Watch for base64/double encoding inflating payload size.
- Set inputLimitBytes deliberately based on your workload, not the default.
When it happens
Trigger: Calling the worker deployment with input whose Buffer/string byteLength exceeds inputLimitBytes — via the stdinPath/stageInput path when preparing stdin input or a staged input file.
Common situations: Passing large JSON payloads, embeddings, or file blobs as worker input; inputLimitBytes configured too small for the workload; double-encoded (base64) input inflating byte size; forgetting to chunk large inputs.
Related errors
- Invalid environment variable name: "${key}"
- Unknown worker resource limit: ${name}.
- Worker resourceLimits.${name} must be a positive safe intege
- Worker executionId must contain only letters, numbers, dots,
- GitHub pull requests require an owner/repository source.
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/770f09923b9bcc2e.
Report an issue: GitHub.