fix(desktop): stop reporting normal renderer exits as errors

Merged
SA
3mo ago
+58-7

Problem

#6191 added an error-level Sentry.captureMessage on every render-process-gone, with no filter on details.reason:

Sentry.captureMessage(`renderer process gone (${details.reason})`, { level: "error", ... });

Electron emits that event for clean-exit (the renderer going away on quit) and killed (reload, window teardown) as well as for real crashes. So once 1.21.0 ships, ordinary app usage files error-level events.

It is unreleased, so there is no production volume yet. That is precisely why it is worth catching now rather than after a release manufactures the noise this automation exists to remove.

Flagged on #6191 by an automated reviewer, verified against the code, and not covered by #6437.

Root cause

The capture was added without a reason filter. render-process-gone is a lifecycle event, not a crash event.

Fix

isExpectedRendererExit(reason) in main/lib/renderer-exit.ts, applied at the capture site.

Deliberately an exclude-list (clean-exit, killed) rather than an allow-list of crash reasons: an unrecognised reason — including one a future Electron version introduces — reports by default. Silence has to be opted into one reason at a time, so a new crash mode can never be lost to this filter.

Still reporting: crashed, oom, launch-failed, integrity-failure, abnormal-exit, and anything unrecognised. The console.error and log.error lines are untouched, so every termination is still in main.log regardless.

Verification

$ bunx biome check apps/desktop/src/main/lib/renderer-exit.ts apps/desktop/src/main/lib/renderer-exit.test.ts apps/desktop/src/main/windows/main.ts
Checked 3 files in 35ms. No fixes applied.

$ bun test apps/desktop/src/main/lib/renderer-exit.test.ts
 3 pass
 0 fail
 9 expect() calls

$ cd apps/desktop && bun run typecheck
$ tsc --noEmit      (clean)

No Refs line: this fixes an unreleased regression introduced by #6191, so no Sentry issue exists for it — the capture had not shipped to any release yet.

(An earlier revision of this body cited DESKTOP-VW. That was wrong: DESKTOP-VW is a crashpad minidump from a mojo bad-message, raised by the native crash handler, and is unaffected by this JS-side reason filter. It remains archived.)


Summary by cubic

Stops treating normal Electron renderer exits as errors. Previously we captured an error-level Sentry.captureMessage on every render-process-gone; now we exclude clean-exit and killed while still reporting real faults and any unknown reasons. Addresses DESKTOP-VW.

  • Adds isExpectedRendererExit and guards the capture in main/windows/main.ts; new module and tests in main/lib/renderer-exit.{ts,test.ts}.
  • Exclude-list by design: crashed, oom, launch-failed, integrity-failure, abnormal-exit, and unrecognized reasons still report.
  • Logging unchanged; all terminations continue to appear in main.log. No migrations required.
  • QA: quit/reload should not create Sentry error events; induce a crash/oom to verify an error event is captured.

Summary by CodeRabbit

  • Bug Fixes

    • Normal renderer shutdowns and intentional terminations are no longer reported as errors.
    • Unexpected renderer exits continue to be captured with diagnostic details for troubleshooting.
  • Tests

    • Added coverage for expected, known-fault, unknown, and empty renderer termination reasons.