{"record":{"id":"42bb479da7899b12","repo":"Hmbown/CodeWhale","slug":"import-exceeds-the-this-maxevents-tolocalestring-event-limit-42bb47","errorCode":null,"errorMessage":"Import exceeds the ${this.maxEvents.toLocaleString()} event limit.","messagePattern":"Import exceeds the (.+?) event limit\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"pet/ios/Resources/pet-native.js","lineNumber":2267,"sourceCode":"    get retainedBytes() { return this.bytes; }\n    measure(event, proposed = event) {\n        const safe = this.project(proposed);\n        if (this.maxBytes !== Infinity) {\n            const size = new TextEncoder().encode(JSON.stringify(safe)).length;\n            const total = this.bytes - (this.sizes.get(event) ?? 0) + size;\n            if (total > this.maxBytes)\n                throw new Error('Runtime observation exceeds its retained input limit.');\n            this.bytes = total;\n            this.sizes.set(event, size);\n        }\n        for (const key of Object.keys(event))\n            if (!Object.hasOwn(safe, key))\n                delete event[key];\n        Object.assign(event, safe);\n    }\n    push(event) {\n        if (this.events.length >= this.maxEvents)\n            throw new Error(`Import exceeds the ${this.maxEvents.toLocaleString()} event limit.`);\n        this.measure(event);\n        pushEvent(this.events, event);\n    }\n    /** Keep unfinished lifetimes plus the recent window needed by the bucketer's\n     * 12-second recurrence measure. A completion may still arrive for any open item. */\n    prune(beforeWall) {\n        if (!Number.isFinite(beforeWall))\n            throw new Error('Invalid Runtime retention horizon.');\n        if (this.origin === undefined)\n            return;\n        const cutoff = beforeWall - this.origin;\n        let keep = 0;\n        for (const event of this.events) {\n            if (event.openEnded || Math.max(event.endTime, (0, model_js_1.errorOnsetOf)(event)) >= cutoff)\n                this.events[keep++] = event;\n            else {\n                this.bytes -= this.sizes.get(event) ?? 0;\n                this.sizes.delete(event);","sourceCodeStart":2249,"sourceCodeEnd":2285,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/pet/ios/Resources/pet-native.js#L2249-L2285","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Increase the maxEvents option used to construct the Runtime retention object.","Call prune(beforeWall) periodically during import to evict completed events.","Split the runtime file into smaller windows and import them separately.","Verify you are not double-importing the same records into one Runtime."],"exampleFix":"// before\nruntime.push(event); // throws at maxEvents\n// after\nif (runtime.events.length >= runtime.maxEvents) {\n  runtime.prune(currentWallTime);\n}\nruntime.push(event);","handlingStrategy":"validation","validationCode":"if (runtime.events.length >= runtime.maxEvents) {\n  runtime.prune(currentWallTime()); // evict finished lifetimes first\n}","typeGuard":"function canAcceptEvent(runtime) {\n  return runtime.events.length < runtime.maxEvents;\n}","tryCatchPattern":"try {\n  runtime.push(event);\n} catch (e) {\n  if (String(e.message).includes('event limit')) {\n    console.error('Runtime hit maxEvents; raise the cap or prune completed events.');\n  } else throw e;\n}","preventionTips":["Size maxEvents to the recording length (records minus skipped deltas).","Prune regularly during long streaming imports.","Do not import multiple recordings into one Runtime object.","Guard against double-importing the same file."],"tags":["import","limit","events"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-22T16:17:23.217Z"}