{"record":{"id":"b65bc64642a928f9","repo":"Hmbown/CodeWhale","slug":"runtime-observation-exceeds-its-retained-input-limit-pet","errorCode":null,"errorMessage":"Runtime observation exceeds its retained input limit.","messagePattern":"Runtime observation exceeds its retained input limit\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"pet/ios/Resources/pet-native.js","lineNumber":2256,"sourceCode":"    origin;\n    model;\n    threadId;\n    threadName;\n    constructor(filename = 'Codewhale runtime', maxEvents = 250_000, project = event => event, maxBytes = Infinity) {\n        this.filename = filename;\n        this.maxEvents = maxEvents;\n        this.project = project;\n        this.maxBytes = maxBytes;\n    }\n    get retainedEvents() { return this.events.length; }\n    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))","sourceCodeStart":2238,"sourceCodeEnd":2274,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/pet/ios/Resources/pet-native.js#L2238-L2274","documentation":"Thrown by the Runtime retention tracker's measure() when adding/updating an observation would push the total retained JSON byte size past maxBytes. The library bounds how much raw runtime input it keeps in memory; an event that does not fit (after projection) aborts the operation. It is a capacity guard on retained input, distinct from the event-count limit.","triggerScenarios":"Calling push() (or otherwise measuring an event) on the Runtime retention object when bytes - existingSize(event) + newEventSize > maxBytes, i.e. the serialized event would exceed the configured byte budget at pet/ios/Resources/pet-native.js:2256. Also triggered by updates that grow an already-tracked event beyond remaining budget.","commonSituations":"Importing a runtime file with a very large maxBytes too small for one huge event; a single event whose attributes ballooned (e.g. a captured error or huge payload); lowering maxBytes below current usage then pushing more events.","solutions":["Increase the maxBytes retention limit configured for the Runtime tracker.","Trim oversized event attributes/payloads before pushing (project or drop large fields).","Enable pruning (prune(beforeWall)) to free budget before pushing more events.","Check which single event is oversized; a pathological attribute is usually the cause."],"exampleFix":"// before\nruntime.push(event); // throws if over maxBytes\n// after\nconst size = new TextEncoder().encode(JSON.stringify(event)).length;\nif (size > runtime.maxBytes) {\n  event.attributes = { ...event.attributes, payload: '[omitted]' };\n}\nruntime.push(event);","handlingStrategy":"validation","validationCode":"const size = new TextEncoder().encode(JSON.stringify(event)).length;\nif (size > runtime.maxBytes) {\n  event.attributes = { ...event.attributes, payload: '[omitted: too large]' };\n}","typeGuard":"function fitsRetainedBudget(event, runtime) {\n  const size = new TextEncoder().encode(JSON.stringify(event)).length;\n  return size <= runtime.maxBytes;\n}","tryCatchPattern":"try {\n  runtime.push(event);\n} catch (e) {\n  if (String(e.message).includes('retained input limit')) {\n    console.error('Event exceeds retention budget; trim attributes or raise maxBytes.');\n  } else throw e;\n}","preventionTips":["Measure event JSON size before pushing huge payloads.","Call prune() periodically during streaming imports to free budget.","Avoid retaining raw payloads in event attributes.","Configure maxBytes above the largest single event you expect."],"tags":["memory","limit","bytes"],"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"}