Repository navigation
chore: add stack trace to boundary - #8040
Conversation
WalkthroughErrorBoundary's error fallback UI is redesigned to extract and display the JavaScript stack trace. The component now derives ChangesErrorBoundary Error Display Enhancement
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 winAdd
rel="noopener noreferrer"for security.External links with
target="_blank"should includerel="noopener noreferrer"to prevent the opened page from accessingwindow.openerand 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 liftAdd cleanup for
window.onerrorhandler and update error handling approach.Three issues with the current implementation:
- Memory leak: No cleanup in
componentWillUnmountmeans the handler persists after the component unmounts.- Overwrites existing handlers: Direct assignment to
window.onerrorwill overwrite any other error handlers.- React 19 incompatibility: React 19 error handling uses root-level callbacks (
onCaughtError/onUncaughtErrorincreateRoot), notwindow.onerror. This handler won't integrate with React's error boundary system.Use
addEventListenerwith cleanup incomponentWillUnmount, 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 valueConsider using
<button>instead of<a>for better semantics.The Force Quit action uses an anchor tag with
href=""andpreventDefault, 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
📒 Files selected for processing (1)
packages/bruno-app/src/pages/ErrorBoundary/index.js
There was a problem hiding this comment.
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.stackorerrorInfo.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.
Description
Contribution Checklist:
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