Repository navigation
Preserve window.onerror details, fix ResizeObserver loop guard, and defer Tooltip resize updates - #23228
Merged
Conversation
…tack Previously, `withSourceMappedStack` replaced both `name` and `message` with `[Unknown]` and dropped `stack` whenever it received a value that was not a string and lacked `name`/`message` properties (such as `null`, `undefined`, primitives, DOM `Event`s, or plain objects). As a result, unrelated renderer crashes collapsed into a single `[Unknown]: [Unknown]` Sentry issue (`DESKTOP-2T5`) with no actionable context. Update `withSourceMappedStack` to: - Report `null`, `undefined`, primitives (using `String(...)` so symbols cannot throw), and functions under `NonError` with their type/value. - Report DOM `Event` objects using their constructor name and event `type`, and other non-Error objects using their constructor name and sorted own property names only (omitting values to avoid leaking sensitive data). - Preserve string `stack` properties on cross-realm or plain Error-like objects where `error instanceof Error` is false. - Guard property access and `JSON.stringify` against throwing getters, null-prototype objects, and circular references so crash reporting cannot throw recursively. Add unit tests covering standard errors, cross-realm Error-like objects, strings, null/undefined, primitives, functions, DOM events, plain and null-prototype objects, circular `message` values, and throwing getters.
Electron's default renderer `window.onerror` bridge forwards only the
5th argument (`error`) to `process.emit('uncaughtException', error)`,
discarding `message`, `source`, `lineno`, and `colno`. When Chromium
reports `ResizeObserver loop completed with undelivered notifications.`,
`window.onerror` receives `error === null`, so Electron emitted
`uncaughtException(null)`. Desktop's `onUncaughtException` guard for
ResizeObserver loop notifications never matched `null`, causing a fatal
crash reported to Sentry as `[Unknown]: [Unknown]` (`DESKTOP-2T5`) and
leaving `resizeObserverLoopCompleted` non-fatal reporting with zero
events.
Introduce `app/src/ui/lib/uncaught-exception.ts` and wire it in
`app/src/ui/index.tsx`:
- Add `mapSourceLocation` to `app/src/lib/source-map-support.ts` to
resolve 1-based bundle `lineno`/`colno` pairs through source maps.
- Add `normalizeWindowError` and `installWindowErrorHandler` to replace
Electron's `window.onerror` handler in the renderer while preserving
its `listenerCount('uncaughtException')` return semantics. Real
`Error` instances are forwarded untouched; when `error` is `null`,
`undefined`, or a non-Error value, the window error message and
source-mapped `source:line:col` location (when `lineno > 0`) are
preserved on a synthetic `Error` without capturing a misleading
`window.onerror` stack trace.
- Add `isResizeObserverLoopError` so `onUncaughtException` matches both
known Chromium ResizeObserver loop notifications and routes them to
`sendNonFatalException('resizeObserverLoopCompleted', ...)` instead of
crashing the application.
Add unit tests covering `isResizeObserverLoopError`,
`normalizeWindowError`, and `installWindowErrorHandler`.
`Tooltip` was the only `ResizeObserver` consumer in the UI still calling `this.setState(...)` synchronously inside its `ResizeObserver` callback. Repositioning a tooltip synchronously during resize observation (for example, when placement near a viewport edge causes text wrapping or box size changes) can trigger Chromium's `ResizeObserver loop completed with undelivered notifications.` error. Defer tooltip and target re-measurement and `setState` updates to `requestAnimationFrame`, coalescing multiple resize notifications per frame to match the rest of the codebase (`Dialog`, `RichText`, `List`, `SectionList`, and `ExpandableCommitSummary`). Cancel pending resize animation frames when the tooltip element detaches, and cancel timers, pending animation frames, and `resizeObserver` on unmount. Add UI component tests verifying that `Tooltip` defers layout updates until the next animation frame, coalesces repeated resize notifications, and cancels pending frames and disconnects its observer on unmount.
Reading `error.name.length` directly when normalizing a thrown function would throw if the function defines a throwing `name` getter or a non-string `name` value, aborting `normalizeWindowError` and crash reporting before the exception reaches Desktop's handler. Read the `name` property through `safeReadProperty` and verify it is a non-empty string before formatting it, falling back to `anonymous function`. Add unit tests covering both throwing `name` getters and non-string `name` values on thrown functions.
Central's `JsException` parser scans every line of `stack` matching `/^\s*at\s(.+?)$/` without sanitizing stack frames the way it sanitizes `message`. If a thrown non-Error string or object contained a newline followed by an `at ...` line (or an `at`-prefixed `name`), `formatWindowErrorStack` embedded it verbatim into the synthetic stack header, allowing message text (including local user paths) to be parsed as unsanitized Sentry stack frames. Collapse line breaks in the synthetic stack header and guard against `at`-prefixed names so only the genuine mapped source location appears on an `at ` line. Add regression tests for multiline strings and `at`-prefixed names.
…ssion `sendNonFatalException` enforces a single shared 1-per-minute throttle across all `ExceptionKinds`. Because Chromium can emit `ResizeObserver loop completed with undelivered notifications.` on every animation frame while a loop persists, reporting every matched loop notification would repeatedly consume the shared non-fatal slot and drop unrelated non-fatal telemetry (`unhandledRejection`, `copilotConflictResolution`, etc.). Extract `createRendererUncaughtExceptionHandler` in `app/src/ui/lib/uncaught-exception.ts` and wire it in `app/src/ui/index.tsx` so `resizeObserverLoopCompleted` is reported at most once per renderer session while still suppressing subsequent loop notifications without detaching the `uncaughtException` listener. Add a regression test covering once-per-session reporting, listener retention across ignored ResizeObserver loops, and listener detachment after a fatal error.
Cover two gaps identified during review: - Exercise `mapSourceLocation` directly against both unmapped files (preserving 1-based line/column and omitting 0/undefined columns) and a real `renderer.js` + `renderer.js.map` pair via `enableSourceMaps()` to verify 1-based to 0-based column conversion end-to-end. - Exercise `Tooltip.onTooltipRef(null)` by hiding a visible tooltip on `mouseleave` while a resize `requestAnimationFrame` is pending, confirming the pending frame is cancelled and the observer is disconnected.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The constructor-name check accepts an array, which causes stack-header sanitization to throw and prevents the original exception from reaching the uncaught-exception listener.
1 open issue
What changed in this PR
This PR improves GitHub Desktop’s renderer crash diagnostics and prevents benign ResizeObserver loop notifications from triggering fatal errors, addressing the missing-error-details path reported in #20760 and #21311.
Changes:
- Preserve
window.onerrormessages and source locations, and improve non-Error formatting. - Handle ResizeObserver loop notifications as non-fatal, reporting at most once per renderer session.
- Defer Tooltip resize updates to animation frames and add regression coverage for scheduling, cleanup, and error handling.
| File | Description |
|---|---|
app/test/unit/ui/uncaught-exception-test.ts |
Tests error normalization, bridge behavior, and non-fatal loop handling. |
app/test/unit/ui/tooltip-test.tsx |
Tests deferred resize updates, coalescing, and cleanup. |
app/test/unit/source-map-support-test.ts |
Tests non-Error diagnostics and source-location mapping. |
app/src/ui/lib/uncaught-exception.ts |
Adds error normalization and renderer exception handlers. |
app/src/ui/lib/tooltip.tsx |
Defers resize updates and cancels pending work on cleanup. |
app/src/ui/index.tsx |
Installs the new renderer error-handling pipeline. |
app/src/lib/source-map-support.ts |
Expands diagnostic formatting and exports source-location mapping. |
Review effort: Balanced
Review feedback: F1 (#23228 (comment)). getConstructorName checked `typeof ctor === 'function' && ctor.name.length > 0` without verifying `typeof ctor.name === 'string'`. Because Function.prototype.name is configurable, a constructor whose `name` property was redefined to a non-string with a positive `.length` (such as an array) passed the check and returned a non-string value as `error.name`. That broke the `string` return contract of `withSourceMappedStack` and threw `TypeError: text.replace is not a function` inside `sanitizeStackHeaderText` when `normalizeWindowError` formatted a synthetic stack header. This defect was introduced by this PR. Read `ctor.name` once via `safeReadProperty(ctor, 'name')` and return it only when `typeof nameProp.value === 'string' && nameProp.value.length > 0`, falling back to `undefined` otherwise. Added regression tests covering both `withSourceMappedStack` and `normalizeWindowError` with a non-string `constructor.name`. Validation: - Regression tests reproduced both failures before the fix and passed after. - `npm test -- app/test/unit/source-map-support-test.ts app/test/unit/ui/uncaught-exception-test.ts app/test/unit/ui/tooltip-test.tsx`: 30/30 passed. - `npx tsc --noEmit`: passed. - `npm run lint`: passed.
sergiou87
marked this pull request as ready for review
November 25, 2026 13:24
sergiou87
enabled auto-merge
November 25, 2026 17:20
tidy-dev
approved these changes
Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
bd7d9244b3ef408eedabd49f2cfe7d24312063benpm run lint,tsc --noEmit, and a 5-bundle production webpack build passed atbd7d9244b3.↑ Author manually verified ResizeObserver loop suppression and
null-error reporting in a running build.↓ Full
npm testhad 4 pre-existing local Git failures (push-test.tsx3,rev-parse-test.tsx1); CI checks have not run yet; deferring Tooltip resize updates trades a 1-frame positioning delay when already-visible tooltip content changes size.window.onerrorreceiveserror === nullforResizeObserver loop completed with undelivered notifications.and Electron'slib/renderer/init.tsforwards onlyerrortouncaughtException, bypassing the existing guard.↑ Confirmed
withSourceMappedStackturnsnulland non-Error values withoutname/messageinto[Unknown]: [Unknown]andTooltipwas the only synchronousResizeObserversetStatecaller.[Unknown]: [Unknown]renderer crash signatures (no stack, no non-fatalkind, zeroresizeObserverLoopCompletedreports) and reproduces the samenull-error path previously seen in #20760 and #21311.↓ Existing
[Unknown]: [Unknown]reports contain no stack or error message, so post-release telemetry is needed to confirm whether ResizeObserver loops account for all of the spike versus anothernull/non-Error source that this change will now unmask.No tracking GitHub issue; addresses production
[Unknown]: [Unknown]renderer crashes with missing stack traces.Description
Production crash telemetry showed a spike in
[Unknown]: [Unknown]renderer crashes with no stack trace. Tracing the renderer uncaught-exception pipeline uncovered three related gaps:window.onerrorbridge drops error details whenerrorisnull: Electron's default rendererwindow.onerrorhandler forwards only its 5therrorargument toprocess.emit('uncaughtException', error), discardingmessage,source,lineno, andcolno. When Chromium emitsResizeObserver loop completed with undelivered notifications.,errorisnull, so Desktop's existingResizeObserverguard inapp/src/ui/index.tsxnever matched and crashed the app instead of treating the notification as non-fatal.withSourceMappedStackcollapsed non-Error values to[Unknown]: [Unknown]: Any thrownnull,undefined, primitive, function, DOMEvent, or plain object withoutname/messageproperties lost all diagnostic detail and its stack.TooltipcalledsetStatesynchronously insideResizeObserver: Unlike every otherResizeObserverconsumer in the UI (Dialog,RichText,List,SectionList,ExpandableCommitSummary),Tooltipupdated state synchronously inside itsResizeObservercallback.Changes
app/src/lib/source-map-support.ts):withSourceMappedStackto reportnull,undefined, primitives (safely formatted withString(...)), and functions underNonError, DOMEventobjects with their constructor name andtype, and other non-Error objects with their constructor name and sorted own property keys only (omitting values to avoid leaking sensitive data).stackproperties on cross-realm/Error-like objects and guard property/function-name reads andJSON.stringifyagainst throwing getters, null-prototype objects, and circular references.mapSourceLocationto resolve 1-based bundle line/column positions through source maps.window.onerrorbridge and ResizeObserver handling (app/src/ui/lib/uncaught-exception.ts,app/src/ui/index.tsx):window.onerrorbridge viainstallWindowErrorHandlerwhile preservinglistenerCount('uncaughtException')return semantics. RealErrorinstances pass through unchanged;null,undefined, and non-Error values preservemessageand a source-mappedsource:line:colframe whenlineno > 0.at-prefixed names in synthetic stack headers so message text cannot be parsed as synthetic stack frames.createRendererUncaughtExceptionHandlerto match ChromiumResizeObserverloop notifications (isResizeObserverLoopError), reportresizeObserverLoopCompletedat most once per renderer session (avoiding starvation of the shared 1-per-minutesendNonFatalExceptionrate limit), and keep theuncaughtExceptionlistener attached until an actual fatal error occurs.Tooltipresize handling (app/src/ui/lib/tooltip.tsx):ResizeObserverre-measurement andsetStateupdates torequestAnimationFramewith per-frame coalescing, cancelling pending frames when the tooltip detaches or unmounts and disconnecting the observer and hide timer on unmount.transformapplies on the next animation frame rather than synchronously before paint (initial display is unaffected becauseonTooltipRefmeasures synchronously).Validation
Covered at commit
bd7d9244b3ef408eedabd49f2cfe7d24312063be(macOS arm64, Node v24.22.1):npm test -- app/test/unit/source-map-support-test.ts app/test/unit/ui/uncaught-exception-test.ts app/test/unit/ui/tooltip-test.tsx app/test/unit/ui/issues-autocompletion-provider-test.tsx— passed (35/35 tests, covering realrenderer.js+renderer.js.mapsource-map lookup, non-Error formatting, multiline stack-header sanitization, once-per-session ResizeObserver handling, and Tooltip rAF deferral/hide/unmount cleanup).npm run lint(Prettier + ESLint) — passed.npx tsc --noEmit— passed.NODE_ENV=production TS_NODE_PROJECT=script/tsconfig.json NODE_OPTIONS='--max_old_space_size=8192' npx webpack --config app/webpack.production.ts— passed (all 5 production bundles compiled; note default 4096 MB heap hits the existing OOM tracked in Raise production webpack heap limit to 8 GiB #23224).npm test— 3,633 passed, 2 skipped, 4 failed (the 4 failures are pre-existing local Git environment failures unrelated to this PR: 3 inapp/test/unit/git/push-test.tsand 1 inapp/test/unit/git/rev-parse-test.ts).nullerrors preserve their message and location instead of[Unknown]: [Unknown].Screenshots
N/A — non-visual crash handling and internal
Tooltipresize scheduling changes.Release notes
Notes: [Fixed] Prevent unnecessary crashes from ResizeObserver loop notifications and improve unknown crash diagnostics
Team-authored review
Evidence: See the Validation section in Description (covering commit
bd7d9244b3ef408eedabd49f2cfe7d24312063be) and the author's manual verification. No visual artifact: changes affect error normalization, renderer error routing, and Tooltip resize scheduling rather than visual UI.Review path: Lightweight review. Author has assessed the changes and evidence; no changes to authentication, credentials, permissions, trust boundaries, destructive operations, release signing, or update mechanisms.