revert(desktop): drop the renderer heap-trajectory Sentry instrumentation

Merged
SA
3mo ago
+0-173

Problem

#6496 added a permanent renderer heap sampler and a Sentry scope trajectory to make two OOM minidumps (DESKTOP-Y3, DESKTOP-Y8) diagnosable. On review after merge, it does not clear the bar for permanently maintained code.

Why it is being reverted

The mechanism was correct — renderer setTag/setExtra genuinely do reach a minidump, and contexts genuinely would not — so this is not a revert for being broken. It is a revert for not being worth its keep:

  • Two events justified it. One occurrence each, on 1.20.2, on different platforms. That is not a demonstrated recurring family; it is two data points that happened to land on the same day.
  • It is permanent. A 5-minute interval for the life of every renderer, plus a tag on every renderer event, with no removal condition and nobody owning its retirement. Instrumentation added speculatively tends to stay forever.
  • The sample interval is incoherent with its own source. performance.memory is quantized and refreshed far more coarsely than 5 minutes without --enable-precise-memory-info, which we deliberately do not set. Early history therefore carries repeated identical readings. The stride-doubling self-corrects on multi-day sessions, but the chosen interval buys nothing over a much cheaper one.
  • The non-trivial logic is untested. recordHeapSample's halving decimation and summarizeHeap's growth-rate maths shipped with no unit tests.
  • It cannot capture the failure it was partly aimed at. DESKTOP-Y8 is a PartitionAlloc commit failure inside a single JSON.stringify, not JS-heap accumulation. A 5-minute sampler of usedJSHeapSize cannot see that spike.

What is kept

Nothing is lost by reverting. The findings that came out of the work are recorded outside the code:

  • Renderer Sentry scope reaches native crash reports only via tags/extra/user/attachments/breadcrumbs; setContext is dropped by handleScope in @sentry/electron 7.16.0. Anyone adding renderer enrichment later needs this and should not rediscover it.
  • DESKTOP-Y3 and DESKTOP-Y8 are two different causes, not one family: a slow retainer over ~75h uptime versus a single enormous serialization in ~5h.
  • Chromium already ships v8-oom-* crash keys for V8 heap-limit aborts (Y3 has them), and none for PartitionAlloc aborts (Y8 has none). Uptime is already derivable from app.app_start_time.
  • Unverified hypothesis worth pursuing on its own merits, code untouched: since #6328 every renderer TanStack DB collection is localStorage-backed, and a localStorage collection re-serializes the whole org blob per mutation — which fits both crash shapes.

If this family recurs at volume, the right move is to fix the retainer, not to instrument around it.

Verification

  • bunx biome check apps/desktop/src/renderer/lib/sentry.ts → Checked 1 file in 10ms. No fixes applied.
  • cd apps/desktop && bun run typecheck → clean, no diagnostics.
  • git diff 92fab2ca5 HEAD is empty: the tree is byte-identical to the commit immediately before #6496, so this is an exact revert with no incidental changes.

Refs DESKTOP-Y3
Refs DESKTOP-Y8


Summary by cubic

Reverts the renderer heap-trajectory Sentry instrumentation from #6496 to remove a permanent 5-minute heap sampler and scope tags/extras that don’t meet our bar for long-term maintenance or diagnosability.

  • Deletes apps/desktop/src/renderer/lib/heap-trajectory.ts and removes the sampler from apps/desktop/src/renderer/lib/sentry.ts.
  • Restores pre-#6496 behavior: no renderer_heap extra, no renderer.heap_used tag, and no periodic performance.memory reads.
  • Reduces renderer overhead; crash reports rely on Chromium v8-oom-* keys as before.

Summary by CodeRabbit

  • Removed Features
    • Removed heap usage tracking and trajectory reporting from the desktop application.
    • Sentry initialization no longer starts background heap monitoring.