diff --git a/src/utils/fileHistory.ts b/src/utils/fileHistory.ts index 414c312ab..c43aabbf9 100644 --- a/src/utils/fileHistory.ts +++ b/src/utils/fileHistory.ts @@ -51,8 +51,9 @@ export type FileHistoryState = { snapshotSequence: number } -// Disabled: file checkpointing causes unbounded memory growth (100 snapshots × full file backups). -// See heap snapshot analysis — re-enable only after switching to incremental diffs. +// Throttled: file checkpointing remains enabled (gated by fileHistoryEnabled()) +// but capped to mitigate unbounded memory growth (full file backups x N snapshots). +// See heap snapshot analysis; only raise this cap after switching to incremental diffs. const MAX_SNAPSHOTS = 20 export type DiffStats = | { diff --git a/src/utils/performanceShim.ts b/src/utils/performanceShim.ts index 486fc5fa5..7bec8da41 100644 --- a/src/utils/performanceShim.ts +++ b/src/utils/performanceShim.ts @@ -145,10 +145,11 @@ const shim = { return original.timeOrigin }, get onresourcetimingbufferfull() { - return (original as any).onresourcetimingbufferfull + return (original as Performance & { onresourcetimingbufferfull?: unknown }) + .onresourcetimingbufferfull }, - set onresourcetimingbufferfull(_v: any) { - // no-op — prevent accumulation + set onresourcetimingbufferfull(_v: unknown) { + // no-op to prevent accumulation }, toJSON() { return original.toJSON() @@ -161,8 +162,11 @@ const shim = { * native Performance reference. */ export function installPerformanceShim(): void { - if ((globalThis as any).__performanceShimInstalled) return - ;(globalThis as any).__performanceShimInstalled = true + const g = globalThis as typeof globalThis & { + __performanceShimInstalled?: boolean + } + if (g.__performanceShimInstalled) return + g.__performanceShimInstalled = true globalThis.performance = shim }