affaan-m/ECC · warning · Error
memory body is too large (maximum ${maxBytes} bytes).
Error message
memory body is too large (maximum ${maxBytes} bytes). What it means
After successfully reading stdin (or a body file), readBoundedStdin/readBody check that total bytes did not exceed MAX_BODY_BYTES (64 * 1024 = 65536 bytes, from memory-vault-format.js). If the body is larger, it throws. The cap exists to keep memory documents small, scannable, and safe against memory-exhaustion via oversized memories; it is also enforced upstream on document size (MAX_DOCUMENT_BYTES = 128 KiB).
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 01e15490f0)
Solutions
- Trim the body to the essentials (under 64 KiB) before saving.
- Store the large artifact elsewhere and save a memory that links to it (use --link <memory-id> and a short summary body).
- Check size first: `wc -c body.md` and ensure it is < 65536.
- Split a long body into multiple smaller memories tagged consistently.
Example fix
# before huge_report > body.md # e.g. 200 KiB ecc memory save --title "report" --body-file body.md # throws # after — summarize and link the full report ecc memory save --title "report summary" --body-file summary.md # < 64 KiB # keep the full report in your docs tree; reference it from the summary body
Defensive patterns
Strategy: validation
Validate before calling
// Validate body size against the 64 KiB cap before reading.
const fs = require('fs');
const MAX_BODY_BYTES = 64 * 1024;
function assertBodyWithinLimit(filePath) {
const st = fs.statSync(filePath);
if (st.size > MAX_BODY_BYTES) {
throw new Error(`memory body is too large (maximum ${MAX_BODY_BYTES} bytes); file is ${st.size}.`);
}
} Try / catch
try { body = readBody(options); }
catch (err) {
if (/memory body is too large/.test(err.message)) {
console.error(`${err.message} Trim the body or store the artifact elsewhere and link it.`);
process.exit(2);
} else throw err;
} Prevention
- Check `wc -c <file>` before saving; keep bodies under 64 KiB.
- Store large artifacts in docs and save a short summary memory that links to them.
- Split very long content into several tagged memories.
When it happens
Trigger: Piping or pointing --body-file at a large file: a multi-megabyte log, a full markdown book chapter, a pasted transcript. Feeding a binary/concatenated blob. A redirected file that is bigger than expected.
Common situations: Treating the memory vault as a document store rather than a note store. Forgetting the 64 KiB body cap. A generated report larger than the limit.
Related errors
- memory body is too large (maximum ${MAX_BODY_BYTES} bytes).
- Memory document ${sourcePath} is too large.
- ${label} must be a non-empty string.
- ${label} is too long (maximum ${maxChars} characters).
- ${label} must not contain control or bidirectional formattin
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/7cc9df31d12512b3.
Report an issue: GitHub.