mastra-ai/mastra · error
Unknown worker resource limit: ${name}.
Error message
Unknown worker resource limit: ${name}. What it means
deployWorkerToSandbox's validateOptions whitelists exactly four worker resource limit keys: cpuTimeSeconds, addressSpaceBytes, fileSizeBytes, and openFiles. If you pass options.resourceLimits containing any other key name, deployment aborts before anything is uploaded. This exists so typos and unsupported limit names fail fast instead of being silently ignored at deploy time.
Source
Thrown at deployers/sandbox/src/worker.ts:189
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.`);
}
}
}
}
function validateRelativePath(value: string, label: string): void {
if (!value || posix.isAbsolute(value) || posix.normalize(value).startsWith('..')) {
throw new Error(`Worker ${label} must stay within the deployed artifact root.`);
}View on GitHub (pinned to 75dd419e61)
Solutions
- Rename the offending key to one of the four supported limits: cpuTimeSeconds, addressSpaceBytes, fileSizeBytes, openFiles.
- Use addressSpaceBytes for memory-style limits (it is converted to KB for ulimit -v internally).
- Type the options object as DeployWorkerToSandboxOptions so TypeScript rejects unknown resourceLimits keys at compile time.
- If you need a limit the library does not support, drop that key or file an upstream request; unsupported limits cannot be passed through.
Example fix
// before
await deployWorkerToSandbox({
sandbox,
command: 'node',
resourceLimits: { memoryBytes: 256 * 1024 * 1024, cpuTimeSecs: 30 },
});
// after
await deployWorkerToSandbox({
sandbox,
command: 'node',
resourceLimits: { addressSpaceBytes: 256 * 1024 * 1024, cpuTimeSeconds: 30 },
}); Defensive patterns
Strategy: validation
Validate before calling
const KNOWN_LIMITS = new Set(['cpuTimeSeconds', 'addressSpaceBytes', 'fileSizeBytes', 'openFiles']);
function assertKnownLimits(limits) {
for (const key of Object.keys(limits ?? {})) {
if (!KNOWN_LIMITS.has(key)) throw new Error(`Unsupported resource limit key: ${key}`);
}
}
assertKnownLimits(options.resourceLimits); // call before deployWorkerToSandbox Type guard
function isResourceLimits(v) {
const known = ['cpuTimeSeconds', 'addressSpaceBytes', 'fileSizeBytes', 'openFiles'];
return typeof v === 'object' && v !== null && Object.keys(v).every(k => known.includes(k));
} Try / catch
try {
await deployWorkerToSandbox(options);
} catch (error) {
if (error instanceof Error && error.message.startsWith('Unknown worker resource limit:')) {
const badKey = error.message.match(/limit: (.+)\./)?.[1];
console.error(`Remove or rename resourceLimits.${badKey}; supported keys: cpuTimeSeconds, addressSpaceBytes, fileSizeBytes, openFiles`);
} else throw error;
} Prevention
- Type options as DeployWorkerToSandboxOptions and let excess property checks catch unknown keys at compile time.
- Keep a single shared constants object for limit names instead of typing them inline in configs.
- Write a unit test that validates every resourceLimits object your app constructs against the known key set.
When it happens
Trigger: Passing options.resourceLimits with a key not in {cpuTimeSeconds, addressSpaceBytes, fileSizeBytes, openFiles} to deployWorkerToSandbox — e.g. resourceLimits: { memoryBytes: 134217728 } or { cpu: 2 } or a misspelled cpuTimeSecs. Note addressSpaceKilobytes/fileSizeBlocks are internal normalized fields and are NOT accepted in user options.
Common situations: Typos like cpuTime or openFile; guessing limit names from ulimit flags (-v, -n); copying limit names from another sandbox/worker library; trying to set a memory limit via memoryBytes instead of addressSpaceBytes; upgrading code that used an older or hypothetical API shape.
Related errors
- terminationGraceMs must be greater than zero.
- Worker command must be a non-empty executable path.
- ${name} must be greater than zero.
- Worker resourceLimits.${name} must be a positive safe intege
- @mastra/livekit: set exactly one reply generator — `generate
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/c734740ce77a2f18.
Report an issue: GitHub.