Hmbown/CodeWhale · error · Error

Import exceeds the event limit.

Error message

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

What it means

Thrown during session import when the number of events derived from the session's journal entries/messages would exceed maxEvents, the configured cap for a single import. The check runs before converting each entry, aborting the whole import at the first entry that would overflow the limit. This protects the pet watch renderer from unbounded memory and event count.

Solutions

  1. Split or truncate the session export so each import stays under the event limit.
  2. Raise the maxEvents configuration if memory allows, then retry the import.
  3. Import a narrower time range or prune the journal before export.
  4. Pre-filter the session JSON to remove noise entries (e.g. deltas) before importing.

Example fix

// before
importSession(hugeSession, { maxEvents: 1000 });
// after
importSession(hugeSession, { maxEvents: 50000 });
Defensive patterns

Strategy: validation

Validate before calling

if (session.journal.entries.length > maxEvents) throw new Error('Session too large to import under current limit');

Try / catch

try { importSession(s, { maxEvents }); } catch (e) { if (e.message.startsWith('Import exceeds the')) retryWithHigherLimitOrChunk(s); else throw e; }

Prevention

When it happens

Trigger: Importing a very large or long-running Codewhale session whose journal entries plus messages convert to more than maxEvents timeline events; the loop hits the cap while iterating sourceEntries.

Common situations: Importing weeks-old sessions with tens of thousands of entries; lowering maxEvents via configuration and then importing an old session; re-importing a session after repeated appends grow it past the limit.

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@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/055a56716a582bc2. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/tui/pet_watch/pet-native.js:2067

    }
    const events = [];
    const pending = new Map();
    let seq = 0;
    const originWall = orderOnly ? undefined : sourceEntries.map(e => parseTime(e.created_at)).find((n) => n !== undefined);
    const agentId = 'parent';
    const model = str(metadata.model);
    const provider = str(metadata.model_provider);
    const when = (entry, fallback) => {
        if (orderOnly || originWall === undefined)
            return { start: fallback, open: false };
        const t = parseTime(entry.created_at);
        if (t === undefined)
            return { start: fallback, open: true };
        return { start: t - originWall, open: false };
    };
    for (const entry of sourceEntries) {
        if (events.length >= maxEvents)
            throw new Error(`Import exceeds the ${maxEvents.toLocaleString()} event limit.`);
        const entryId = str(entry.id) ?? `${sessionId}/entry/${seq}`;
        const message = obj(entry.message ?? (entry.kind === 'message' ? entry : {}));
        const role = str(message.role) ?? (str(entry.kind) === 'user' ? 'user' : str(entry.kind) === 'assistant' ? 'assistant' : undefined);
        const blocks = Array.isArray(message.content) ? message.content.map(obj) : [];
        if (!blocks.length) {
            const text = str(entry.text) ?? str(message.text);
            if (text)
                blocks.push({ type: role === 'user' ? 'text' : 'text', text });
        }
        if (!blocks.length)
            continue;
        const parentEventId = events.length ? events[events.length - 1].id : undefined;
        for (const block of blocks) {
            const t = when(entry, seq);
            const idBase = `${entryId}/${seq}`;
            const type = str(block.type) ?? 'text';
            const raw = pointer('codewhale.session/v1', { sessionId, entryId, seq, blockType: type, toolUseId: block.id ?? block.tool_use_id });
            if (type === 'tool_use' || type === 'server_tool_use') {

View on GitHub (pinned to 73e0f67d83)