Skip to content

chore: add stack trace to boundary - #8040

Merged
bijin-bruno merged 1 commit into
usebruno:mainfrom
sid-bruno:chore/copy-error-stack
May 20, 2026
Merged

bijin-bruno merged 1 commit into
usebruno:mainfrom
sid-bruno:chore/copy-error-stack

Conversation

@sid-bruno

@sid-bruno sid-bruno commented May 19, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Screenshot 2026-05-19 at 11 09 25 PM

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • Bug Fixes
    • Redesigned the error screen interface with improved layout and added a dedicated "Stack Trace" panel for clearer error diagnostics and troubleshooting.

Review Change Stack

Copilot AI review requested due to automatic review settings May 19, 2026 17:40
@coderabbitai

coderabbitai Bot commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

ErrorBoundary's error fallback UI is redesigned to extract and display the JavaScript stack trace. The component now derives stackTrace from error.stack or errorInfo.componentStack, updates the layout and styling, reworks action controls with new markup, and renders a dedicated "Stack Trace" panel while preserving the existing error recovery handlers.

Changes

ErrorBoundary Error Display Enhancement

Layer / File(s) Summary
Error fallback UI with stack trace display
packages/bruno-app/src/pages/ErrorBoundary/index.js
Fallback render now destructures error and errorInfo, computes stackTrace with fallback to errorInfo.componentStack, updates JSX structure for the header and error message display, reworks control area markup with updated spacing and dividers, and adds a "Stack Trace" panel to display the computed stack. Return to App, cache-clearing, and Force Quit handlers remain unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🚨 When ErrorBoundary catches a fall,
Stack traces now answer the call—
Fresh layout, new view,
The stack shines on through,
Better error sight for us all!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding stack trace display to the error boundary component's UI.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/bruno-app/src/pages/ErrorBoundary/index.js (2)

57-63: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add rel="noopener noreferrer" for security.

External links with target="_blank" should include rel="noopener noreferrer" to prevent the opened page from accessing window.opener and potential tabnabbing attacks.

🔒 Proposed fix
             <a
               className="text-link hover:underline cursor-pointer ml-2"
               href="https://github.com/usebruno/bruno/issues"
               target="_blank"
+              rel="noopener noreferrer"
             >
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/bruno-app/src/pages/ErrorBoundary/index.js` around lines 57 - 63,
The anchor element rendering the external issue link (the <a ...
href="https://github.com/usebruno/bruno/issues" target="_blank"> node in
ErrorBoundary JSX) must include rel="noopener noreferrer" to prevent
window.opener/tabnabbing; update that anchor to add the rel attribute alongside
the existing className, href and target attributes.

12-17: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Add cleanup for window.onerror handler and update error handling approach.

Three issues with the current implementation:

  1. Memory leak: No cleanup in componentWillUnmount means the handler persists after the component unmounts.
  2. Overwrites existing handlers: Direct assignment to window.onerror will overwrite any other error handlers.
  3. React 19 incompatibility: React 19 error handling uses root-level callbacks (onCaughtError/onUncaughtError in createRoot), not window.onerror. This handler won't integrate with React's error boundary system.

Use addEventListener with cleanup in componentWillUnmount, or consider moving error logging to root-level callbacks if available.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/bruno-app/src/pages/ErrorBoundary/index.js` around lines 12 - 17,
The component currently assigns window.onerror inside componentDidMount on the
ErrorBoundary class which overwrites existing handlers and leaks after unmount;
change to registering a listener via window.addEventListener('error',
this.handleGlobalError) in componentDidMount, implement a bound method
handleGlobalError(event) that extracts error info and calls this.setState({
hasError: true, error: event.error || event.message }), and remove the listener
in componentWillUnmount with window.removeEventListener('error',
this.handleGlobalError); alternatively, if upgrading to React 19, move global
error handling into the root createRoot callbacks
(onCaughtError/onUncaughtError) instead of relying on window.onerror so it
integrates with React’s error system.
🧹 Nitpick comments (1)
packages/bruno-app/src/pages/ErrorBoundary/index.js (1)

90-105: 💤 Low value

Consider using <button> instead of <a> for better semantics.

The Force Quit action uses an anchor tag with href="" and preventDefault, which is not semantic HTML. A <button> element would be more appropriate for this action.

♻️ Proposed refactor
-                <a
-                  href=""
-                  className="text-sm text-red-400 border border-red-400 hover:text-red-600 px-4 py-2 rounded transition cursor-pointer"
+                <button
+                  type="button"
+                  className="text-sm text-red-400 border border-red-400 hover:text-red-600 px-4 py-2 rounded transition cursor-pointer bg-transparent"
                   onClick={async (e) => {
-                    e.preventDefault();
                     try {
                       if (this.state.clearCaches) {
                         await this.clearCache();
                       }
                     } finally {
                       this.forceQuit();
                     }
                   }}
                 >
                   Force Quit
-                </a>
+                </button>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/bruno-app/src/pages/ErrorBoundary/index.js` around lines 90 - 105,
Replace the anchor used for the "Force Quit" action with a semantic button
element: change the <a> to a <button> (use type="button"), remove the href and
the explicit e.preventDefault(), keep the existing className styling and the
onClick handler body that awaits this.clearCache() when this.state.clearCaches
is true and then calls this.forceQuit(); ensure the handler still handles async
errors (the try/finally) and that any accessibility attributes (e.g.,
aria-label) are added if needed in the ErrorBoundary component to maintain
semantics and keyboard behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/bruno-app/src/pages/ErrorBoundary/index.js`:
- Around line 57-63: The anchor element rendering the external issue link (the
<a ... href="https://github.com/usebruno/bruno/issues" target="_blank"> node in
ErrorBoundary JSX) must include rel="noopener noreferrer" to prevent
window.opener/tabnabbing; update that anchor to add the rel attribute alongside
the existing className, href and target attributes.
- Around line 12-17: The component currently assigns window.onerror inside
componentDidMount on the ErrorBoundary class which overwrites existing handlers
and leaks after unmount; change to registering a listener via
window.addEventListener('error', this.handleGlobalError) in componentDidMount,
implement a bound method handleGlobalError(event) that extracts error info and
calls this.setState({ hasError: true, error: event.error || event.message }),
and remove the listener in componentWillUnmount with
window.removeEventListener('error', this.handleGlobalError); alternatively, if
upgrading to React 19, move global error handling into the root createRoot
callbacks (onCaughtError/onUncaughtError) instead of relying on window.onerror
so it integrates with React’s error system.

---

Nitpick comments:
In `@packages/bruno-app/src/pages/ErrorBoundary/index.js`:
- Around line 90-105: Replace the anchor used for the "Force Quit" action with a
semantic button element: change the <a> to a <button> (use type="button"),
remove the href and the explicit e.preventDefault(), keep the existing className
styling and the onClick handler body that awaits this.clearCache() when
this.state.clearCaches is true and then calls this.forceQuit(); ensure the
handler still handles async errors (the try/finally) and that any accessibility
attributes (e.g., aria-label) are added if needed in the ErrorBoundary component
to maintain semantics and keyboard behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a37f277d-5c7c-437e-a491-006f46acc505

📥 Commits

Reviewing files that changed from the base of the PR and between e86a036 and a200166.

📒 Files selected for processing (1)
  • packages/bruno-app/src/pages/ErrorBoundary/index.js

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

Updates the app-level ErrorBoundary page in bruno-app to surface more diagnostic information to users when a React render error occurs, by adding a dedicated stack trace panel alongside the existing recovery actions.

Changes:

  • Compute and display a stack trace (from error.stack or errorInfo.componentStack) when the boundary is tripped.
  • Restructure the error UI into a two-column layout (actions on the left, stack trace/details on the right).
  • Minor styling/layout adjustments (logo size, spacing, separators).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bijin-bruno
bijin-bruno merged commit 2d25b2c into usebruno:main May 20, 2026
21 of 23 checks passed
lyh543 pushed a commit to lyh543/bruno that referenced this pull request May 22, 2026
jattsson pushed a commit to jattsson/bruno that referenced this pull request May 26, 2026
sharan-bruno pushed a commit to sharan-bruno/bruno that referenced this pull request Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants