Skip to content

fix(popup): report the Error to Sentry from the ErrorBoundary, not the stack string - #3012

Open
piyalbasu wants to merge 1 commit into
masterfrom
fix/error-boundary-sentry
Open

piyalbasu wants to merge 1 commit into
masterfrom
fix/error-boundary-sentry

Conversation

@piyalbasu

Copy link
Copy Markdown
Contributor

TL;DR

Every crash caught by the app's error boundary has been arriving in Sentry as an opaque string with no error type, no message and no stack trace — because componentDidCatch reported info.componentStack (a string) instead of the Error itself. This boundary wraps the whole extension, so it applies to every unhandled render error we have.

One line. The component stack is still sent, as context rather than as the payload.

Implementation details (for agents)

What changedErrorBoundary/index.tsx:

- captureException(info.componentStack);
+ captureException(error, { extra: { componentStack: info.componentStack } });

captureException(exception: unknown, hint?: ExclusiveEventHintOrCaptureContext) — checked against the installed @sentry/browser 10.63.0 rather than assumed, so the context object is the supported second argument.

Why it matters. ErrorBoundary wraps the app in App.tsx, so it is the catch-all for render-time throws. Reporting the stack string means Sentry groups those events by a string it cannot parse, with no exception type to filter on and no stack frames to resolve against sourcemaps. Anything the boundary caught was effectively undiagnosable.

Tests. This component had none; the PR adds two:

  • the reported value is an Error, not a string, with its message preserved and the component stack present in context
  • the fallback renders instead of the crashed subtree

The first was confirmed to fail against the old call — reverted the fix, watched it go red, restored it. It is a regression guard, not a passing assertion.

Verification: tsc --noEmit clean, both tests pass, no other files touched.

Provenance. Found while auditing error paths for the token price chart (freighter-private#32), where this boundary is the last line of defence for a render-time throw. Split out because it is a pre-existing bug in shared code that benefits every crash report today, and should not wait on that feature.

🤖 Generated with Claude Code

…e stack string

`componentDidCatch` called `captureException(info.componentStack)`, which
sends a STRING. Every boundary-caught crash therefore arrived in Sentry as
an opaque message with no error type, no message and no stack trace — the
three things that make a crash diagnosable. This boundary wraps the whole
app (`App.tsx`), so that applied to every unhandled render error in the
extension.

Reports the Error itself now, with the component stack carried as context
rather than as the payload. `captureException(exception, hint)` takes a
CaptureContext as its second argument in @sentry/browser 10.x.

Adds the first test coverage for this component: one asserting the
reported value is an Error and not a string — confirmed to fail against
the old call — and one asserting the fallback renders instead of the
crashed subtree.

Found while auditing error paths for the token price chart, where this
boundary is the last line of defence for a render-time throw. Split out
because it is a pre-existing bug in shared code and should not wait on
that feature.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings September 15, 2026 00:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Corrects popup crash reporting by sending the original error to Sentry while retaining React’s component stack as context.

Changes:

  • Reports the caught Error rather than a stack string.
  • Adds regression coverage for Sentry reporting and fallback rendering.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
ErrorBoundary/index.tsx Improves Sentry exception payloads.
ErrorBoundary/__tests__/index.test.tsx Tests reporting and fallback behavior.

Note

Copilot is running an experiment and ran this review at Balanced.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown
Contributor

PR Preview build is ready: https://github.com/stellar/freighter/releases/tag/untagged-d37ef93024a4b3251652
Backend: sandbox (piyalbasu). SDF collaborators only — install instructions in the release description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants