affaan-m/ECC · error · Error
memory body is too large
Error message
memory body is too large (maximum ${maxBytes} bytes). What it means
scripts/memory.js enforces a hard cap on how many bytes it will read from standard input when ingesting a memory body. readBoundedStdin accumulates chunks and throws this error as soon as the cumulative byte total exceeds maxBytes (MAX_BODY_BYTES). It protects the CLI from unbounded stdin (e.g. accidental `cat huge.log | memory save`) before any decode or file write occurs.
Solutions
- Shrink the input: pipe only the relevant snippet (head/sed/grep) or split the content into multiple smaller memory saves.
- Write the content to a file and use --body-file with a pre-check on file size (stat) if the file path flow allows a larger limit.
- Check the configured MAX_BODY_BYTES in scripts/memory.js and raise it deliberately if your workflow legitimately needs larger bodies, then commit that change consciously.
- Pre-measure the payload before invoking: `wc -c` on the piped content to confirm it fits the cap.
Example fix
// before cat full-incident-log.txt | node scripts/memory.js save --stdin --title "incident" // after grep -n 'ERROR' full-incident-log.txt | head -200 | node scripts/memory.js save --stdin --title "incident errors"
Defensive patterns
Strategy: validation
Validate before calling
const size = Number(process.env.CLI_STDIN_BYTES ?? 0);
if (payload.length > MAX_BODY_BYTES) {
throw new Error(`Input is ${payload.length} bytes; memory accepts at most ${MAX_BODY_BYTES}.`);
} Try / catch
try {
runMemorySave(body);
} catch (err) {
if (String(err.message).includes('memory body is too large')) {
console.error('Input exceeds the memory body limit; trim or split the content.');
process.exitCode = 2;
} else throw err;
} Prevention
- Run `wc -c` on piped content before invoking memory save.
- Extract only the relevant excerpt (grep/head) instead of piping whole files.
- Keep MAX_BODY_BYTES in mind when designing CI jobs that stream artifacts to the CLI.
- Prefer --body-file with a size pre-check for large but bounded content.
When it happens
Trigger: Calling `memory save --stdin` (via saveInput -> readBody -> readBoundedStdin) with a stdin payload whose total size exceeds MAX_BODY_BYTES. Any piped or heredoc input larger than the configured maximum triggers the throw after reading completes.
Common situations: Piping a large log, JSON dump, or file into the memory CLI; a CI script that redirects an entire artifact to stdin; forgetting to trim/select the relevant snippet before piping; misjudging the cap after a payload grew over time.
Understand the failure class
Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.
Related errors
- empty stdin
- Invalid issue number
- exceeds the -byte limit
- must be a regular file
- Agents directory not found
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/7cc9df31d12512b3.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/memory.js:188
bytesRead = fs.readSync(0, buffer, 0, buffer.length, null);
} catch (error) {
const retryable = ['EAGAIN', 'EWOULDBLOCK', 'EINTR'].includes(error?.code);
if (!retryable) throw error;
if (remainingRetryWaitMs < retryDelayMs) {
throw new Error(
`Standard input remained unavailable after ${maxRetryWaitMs}ms.`
);
}
wait(retryDelayMs);
remainingRetryWaitMs -= retryDelayMs;
continue;
}
if (bytesRead === 0) break;
chunks.push(buffer.subarray(0, bytesRead));
total += bytesRead;
}
if (total > maxBytes) {
throw new Error(`memory body is too large (maximum ${maxBytes} bytes).`);
}
return decodeUtf8(Buffer.concat(chunks, total), 'memory body from standard input');
}
function readBody(options) {
const sources = [Boolean(options.stdin), Boolean(options.bodyFile)]
.filter(Boolean).length;
if (sources !== 1) {
throw new Error('Choose exactly one memory body source: --stdin or --body-file.');
}
if (options.stdin) {
return readBoundedStdin(MAX_BODY_BYTES);
}
const bodyPath = path.resolve(options.bodyFile);
return readRegularTextFile(bodyPath, {
label: '--body-file',
maxBytes: MAX_BODY_BYTES,View on GitHub (pinned to 8321021c54)