Hmbown/CodeWhale · error · Error
Runtime observation exceeds its retained input limit.
Error message
Runtime observation exceeds its retained input limit.
What it means
The Runtime importer retains events under a byte budget (maxBytes). measure() projects each event to its retained shape, serializes it, and adds its size to the running total. If the total would exceed maxBytes, the import throws instead of silently dropping data. This enforces a hard memory bound on runtime observation retention.
Solutions
- Increase the Runtime's maxBytes budget to accommodate the expected stream size.
- Call prune(beforeWall) to drop completed events outside the retention window before pushing more.
- Import the runtime stream in chunks into separate Runtime instances.
- Serialize/drop large payload fields before pushing events.
Example fix
// before
const rt = new Runtime({ maxBytes: 1024 * 1024 });
// after
const rt = new Runtime({ maxBytes: 64 * 1024 * 1024 }); Defensive patterns
Strategy: try-catch
Validate before calling
const approxBytes = (e) => new TextEncoder().encode(JSON.stringify(e)).length; if (approxBytes(event) > runtime.maxBytes) trimEvent(event);
Try / catch
try { rt.push(event); } catch (e) { if (e.message.includes('retained input limit')) { rt.prune(Date.now()); rt.push(event); } else throw e; } Prevention
- Set maxBytes well above the expected stream size.
- Prune periodically during long imports.
- Strip large payload fields before pushing.
- Monitor rt.bytes growth in long-lived runtimes.
When it happens
Trigger: Pushing an event into a Runtime whose accumulated retained bytes plus the new event's serialized size exceed maxBytes; typically during import of a large runtime event stream or after many pushes into a long-lived Runtime instance.
Common situations: Importing a very large runtime export with the default byte budget; building one Runtime across many threads/sessions until the budget is exhausted; setting a small maxBytes for testing and forgetting it in production code.
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
- Import exceeds the event limit.
- Input exceeds 64 MiB.
- Runtime observation exceeds its retained input limit.
- Scope inventory reached its bound; delete narrower scopes…
- Automation admission execution ownership is unverified or…
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/508cebfe613d6296.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tui/pet_watch/pet-native.js:2256
origin;
model;
threadId;
threadName;
constructor(filename = 'Codewhale runtime', maxEvents = 250_000, project = event => event, maxBytes = Infinity) {
this.filename = filename;
this.maxEvents = maxEvents;
this.project = project;
this.maxBytes = maxBytes;
}
get retainedEvents() { return this.events.length; }
get retainedBytes() { return this.bytes; }
measure(event, proposed = event) {
const safe = this.project(proposed);
if (this.maxBytes !== Infinity) {
const size = new TextEncoder().encode(JSON.stringify(safe)).length;
const total = this.bytes - (this.sizes.get(event) ?? 0) + size;
if (total > this.maxBytes)
throw new Error('Runtime observation exceeds its retained input limit.');
this.bytes = total;
this.sizes.set(event, size);
}
for (const key of Object.keys(event))
if (!Object.hasOwn(safe, key))
delete event[key];
Object.assign(event, safe);
}
push(event) {
if (this.events.length >= this.maxEvents)
throw new Error(`Import exceeds the ${this.maxEvents.toLocaleString()} event limit.`);
this.measure(event);
pushEvent(this.events, event);
}
/** Keep unfinished lifetimes plus the recent window needed by the bucketer's
* 12-second recurrence measure. A completion may still arrive for any open item. */
prune(beforeWall) {
if (!Number.isFinite(beforeWall))View on GitHub (pinned to 73e0f67d83)