affaan-m/ECC · error · Error
Memory document is too large.
Error message
Memory document ${sourcePath} is too large. What it means
parseMemoryDocument() enforces a hard size cap (MAX_DOCUMENT_BYTES) on the UTF-8 byte length of a memory document. This prevents pathological inputs — huge pastes, binary blobs, runaway logs — from consuming memory or stalling parsing; oversized documents are rejected outright.
Solutions
- Trim the document body to under the MAX_DOCUMENT_BYTES limit — move large content to a separate file and reference it.
- Split the memory into multiple smaller memory documents with focused titles.
- Check for accidental duplication/appending in the file (e.g. a loop re-writing content) and regenerate the file.
- Verify you're loading the intended file and not a large dump; check size with `ls -lh` or `wc -c`.
Example fix
// before
const doc = fs.readFileSync('huge-memory.md', 'utf8'); // 20 MB of notes
parseMemoryDocument(doc, 'huge-memory.md');
// after
const doc = fs.readFileSync('huge-memory.md', 'utf8');
if (Buffer.byteLength(doc, 'utf8') > MAX_DOCUMENT_BYTES) {
writeSummaryMemory('huge-memory', summarize(doc)); // store a compact summary instead
} else {
parseMemoryDocument(doc, 'huge-memory.md');
} Defensive patterns
Strategy: validation
Validate before calling
const stat = fs.statSync(path);
if (stat.size > MAX_DOCUMENT_BYTES) {
throw new Error(`${path} exceeds the ${MAX_DOCUMENT_BYTES}-byte memory document limit`);
} Type guard
const isWithinSizeLimit = (s) => typeof s === 'string' && Buffer.byteLength(s, 'utf8') <= MAX_DOCUMENT_BYTES;
Try / catch
try {
parseMemoryDocument(source, path);
} catch (err) {
if (err.message.includes('is too large')) {
console.error('%s exceeds MAX_DOCUMENT_BYTES; split it or store a summary.', path);
} else throw err;
} Prevention
- Check file size (`wc -c`) before loading documents from untrusted sources.
- Keep memory bodies concise; link to external files for long content.
- Avoid append-only scripts that grow memory files unboundedly.
When it happens
Trigger: Parsing a memory document whose UTF-8 encoding exceeds MAX_DOCUMENT_BYTES — e.g. a very large body pasted below the frontmatter, accumulated log content, binary data embedded in the file, or a corrupted/duplicated file.
Common situations: Pasting an entire article or transcript as memory body content; a script appending to the memory file on every run until it balloons; accidentally pointing the loader at a large dump file instead of a memory document.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- application config exceeds local size limit
- candidate configuration exceeds 1 MiB
- is too long (maximum characters).
- memory body is too large
- Nasiko manifest layer size is outside the allowed range.
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/45acc6da6c048e23.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/lib/memory-vault-format.js:251
throw new Error(`Duplicate memory frontmatter field in ${sourcePath}.`);
}
const rawValue = line.slice(separator + 1).trim();
try {
return { objectKey, value: JSON.parse(rawValue) };
} catch {
throw new Error(`Memory frontmatter field in ${sourcePath} must use a JSON value.`);
}
}
function parseMemoryDocument(source, sourcePath = '<memory>') {
const openingMarker = typeof source === 'string'
? /^---\r?\n/.exec(source)
: null;
if (!openingMarker) {
throw new Error(`Memory document ${sourcePath} must start with --- frontmatter.`);
}
if (Buffer.byteLength(source, 'utf8') > MAX_DOCUMENT_BYTES) {
throw new Error(`Memory document ${sourcePath} is too large.`);
}
const frontmatterStart = openingMarker[0].length;
const remainder = source.slice(frontmatterStart);
const closingMarker = /\r?\n---(?=\r?\n|$)/.exec(remainder);
if (!closingMarker) {
throw new Error(`Memory document ${sourcePath} has no closing frontmatter marker.`);
}
const frontmatterSource = remainder.slice(0, closingMarker.index);
const parsed = frontmatterSource.split(/\r?\n/).reduce((state, line) => {
const next = parseFrontmatterLine(line, sourcePath, state.seen);
return {
values: { ...state.values, [next.objectKey]: next.value },
seen: new Set([...state.seen, next.objectKey]),
};
}, { values: {}, seen: new Set() });
View on GitHub (pinned to 8321021c54)