Hmbown/CodeWhale · error · Error

Import exceeds the event limit.

Error message

Import exceeds the ${this.maxEvents.toLocaleString()} event limit.

What it means

Thrown by the Runtime retention tracker's push() when the events array already holds maxEvents items. It caps how many events the runtime import will retain, mirroring the snapshot importer's limit but at the Runtime level. Reaching the cap aborts the push rather than silently dropping events.

Solutions

  1. Increase the maxEvents option used to construct the Runtime retention object.
  2. Call prune(beforeWall) periodically during import to evict completed events.
  3. Split the runtime file into smaller windows and import them separately.
  4. Verify you are not double-importing the same records into one Runtime.

Example fix

// before
runtime.push(event); // throws at maxEvents
// after
if (runtime.events.length >= runtime.maxEvents) {
  runtime.prune(currentWallTime);
}
runtime.push(event);
Defensive patterns

Strategy: validation

Validate before calling

if (runtime.events.length >= runtime.maxEvents) {
  runtime.prune(currentWallTime()); // evict finished lifetimes first
}

Type guard

function canAcceptEvent(runtime) {
  return runtime.events.length < runtime.maxEvents;
}

Try / catch

try {
  runtime.push(event);
} catch (e) {
  if (String(e.message).includes('event limit')) {
    console.error('Runtime hit maxEvents; raise the cap or prune completed events.');
  } else throw e;
}

Prevention

When it happens

Trigger: Calling runtime.push(event) when this.events.length >= this.maxEvents (pet/ios/Resources/pet-native.js:2267), typically during a long runtime import where more non-delta records arrive than the configured cap allows.

Common situations: Importing a very long runtime recording (many hours); setting maxEvents too low for the recording length; failing to call prune() during a streaming import so the array never shrinks; importing multiple recordings into one Runtime object.

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


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/42bb479da7899b12. Report an issue: GitHub.

Appendix: source

Thrown at pet/ios/Resources/pet-native.js:2267

    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))
            throw new Error('Invalid Runtime retention horizon.');
        if (this.origin === undefined)
            return;
        const cutoff = beforeWall - this.origin;
        let keep = 0;
        for (const event of this.events) {
            if (event.openEnded || Math.max(event.endTime, (0, model_js_1.errorOnsetOf)(event)) >= cutoff)
                this.events[keep++] = event;
            else {
                this.bytes -= this.sizes.get(event) ?? 0;
                this.sizes.delete(event);

View on GitHub (pinned to 433685b202)