[PR #4765] [MERGED] Implement Global Error Boundary #4760

Closed
opened 2026-02-22 18:36:28 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/4765
Author: @angelplusultra
Created: 12/11/2025
Status: Merged
Merged: 12/12/2025
Merged by: @timothycarambat

Base: masterHead: enhancement-error-boundary


📝 Commits (6)

📊 Changes

7 files changed (+189 additions, -40 deletions)

View changed files

📝 .github/workflows/dev-build.yaml (+1 -1)
📝 frontend/package.json (+2 -1)
📝 frontend/src/App.jsx (+27 -18)
frontend/src/components/ErrorBoundaryFallback/index.jsx (+93 -0)
📝 frontend/src/main.jsx (+8 -0)
📝 frontend/src/pages/404.jsx (+18 -17)
📝 frontend/yarn.lock (+40 -3)

📄 Description

Pull Request Type

  • feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 🔨 chore
  • 📝 docs

What is in this change?

This PR introduces a global error boundary and fallback component.

Errors React Error Boundaries DO catch

(Anything that happens while React is rendering the UI)

Caught:
• Errors in the function component body
(e.g., accessing undefined, throwing manually)
• Errors while evaluating JSX
• Errors during re-rendering
• Errors during DOM reconciliation/commit
• Errors thrown in child component constructors (rare in functional React)

Mental model:
If the error happens while React is trying to paint the screen, the boundary catches it.

Errors React Error Boundaries DO NOT catch

(Anything that happens after the UI is already on the screen)

Not caught:
• Errors in event handlers
• Errors in async code (fetch, setTimeout, promises, async/await)
• Errors in useEffect / useLayoutEffect
• Errors in manual DOM listeners (window.addEventListener)
• Errors in the Error Boundary’s own fallback UI
• Errors during SSR (server-side rendering)


The error fallback component features the error message, a reset button which will reset the boundary, and a home navigation button which will also reset the boundary and navigate you to /.

If you're running the app in development, the component will also feature the error stack trace as well as a "Copy Details" button which will copy information related to the error to your clipboard.

Error Report
============
Timestamp: 2025-12-11T19:10:21.739Z
URL: http://localhost:3000/settings/system-prompt-variables
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Cursor/2.2.9 Chrome/138.0.7204.251 Electron/37.7.0 Safari/537.36

Error: Error
Message: Test error

Stack Trace:
Error: Test error
    at SystemPromptVariables (http://localhost:3000/src/pages/Admin/SystemPromptVariables/index.jsx:36:9)
    at renderWithHooks (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:11568:26)
    at mountIndeterminateComponent (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:14946:21)
    at beginWork (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:15934:22)
    at beginWork$1 (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:19781:22)
    at performUnitOfWork (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:19226:20)
    at workLoopSync (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:19165:13)
    at renderRootSync (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:19144:15)
    at recoverFromConcurrentError (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:18764:28)
    at performConcurrentWorkOnRoot (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:18712:30)

Development View

image (1)

Production View

image (2)

Additional Information

If you would like to see the error boundary at work just throw an error in a page component and then navigate to that page.

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated
  • I have tested my code functionality
  • Docker build succeeds locally

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/4765 **Author:** [@angelplusultra](https://github.com/angelplusultra) **Created:** 12/11/2025 **Status:** ✅ Merged **Merged:** 12/12/2025 **Merged by:** [@timothycarambat](https://github.com/timothycarambat) **Base:** `master` ← **Head:** `enhancement-error-boundary` --- ### 📝 Commits (6) - [`9f524c1`](https://github.com/Mintplex-Labs/anything-llm/commit/9f524c118cb0fe169288b92f019ea5cf2bb89404) Implement global error boundary - [`35ec53a`](https://github.com/Mintplex-Labs/anything-llm/commit/35ec53ad34fb8e3463bb53a4de83283fe7e2338b) add 404 page for generic path catching - [`06c3436`](https://github.com/Mintplex-Labs/anything-llm/commit/06c3436641d005228493c9592a3e21899ceca417) Merge branch 'master' into enhancement-error-boundary - [`96bc916`](https://github.com/Mintplex-Labs/anything-llm/commit/96bc9161f3709cd79140bf5a557444ef84965594) devbuild - [`559e403`](https://github.com/Mintplex-Labs/anything-llm/commit/559e403a905fe60ef6ee5d2f3be10b60eae6afca) mergeg - [`9df0ea6`](https://github.com/Mintplex-Labs/anything-llm/commit/9df0ea634188534a310956806d15a50adddf58d1) merge master ### 📊 Changes **7 files changed** (+189 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/dev-build.yaml` (+1 -1) 📝 `frontend/package.json` (+2 -1) 📝 `frontend/src/App.jsx` (+27 -18) ➕ `frontend/src/components/ErrorBoundaryFallback/index.jsx` (+93 -0) 📝 `frontend/src/main.jsx` (+8 -0) 📝 `frontend/src/pages/404.jsx` (+18 -17) 📝 `frontend/yarn.lock` (+40 -3) </details> ### 📄 Description ### Pull Request Type <!-- For change type, change [ ] to [x]. --> - [x] ✨ feat - [ ] 🐛 fix - [ ] ♻️ refactor - [ ] 💄 style - [ ] 🔨 chore - [ ] 📝 docs ### What is in this change? <!-- Describe the changes in this PR that are impactful to the repo. --> This PR introduces a global error boundary and fallback component. ### Errors React Error Boundaries DO catch (Anything that happens while React is rendering the UI) Caught: • Errors in the function component body (e.g., accessing undefined, throwing manually) • Errors while evaluating JSX • Errors during re-rendering • Errors during DOM reconciliation/commit • Errors thrown in child component constructors (rare in functional React) Mental model: If the error happens while React is trying to paint the screen, the boundary catches it. ### Errors React Error Boundaries DO NOT catch (Anything that happens after the UI is already on the screen) Not caught: • Errors in event handlers • Errors in async code (fetch, setTimeout, promises, async/await) • Errors in useEffect / useLayoutEffect • Errors in manual DOM listeners (window.addEventListener) • Errors in the Error Boundary’s own fallback UI • Errors during SSR (server-side rendering) --- The error fallback component features the error message, a reset button which will reset the boundary, and a home navigation button which will also reset the boundary and navigate you to `/`. If you're running the app in development, the component will also feature the error stack trace as well as a "Copy Details" button which will copy information related to the error to your clipboard. ``` Error Report ============ Timestamp: 2025-12-11T19:10:21.739Z URL: http://localhost:3000/settings/system-prompt-variables User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Cursor/2.2.9 Chrome/138.0.7204.251 Electron/37.7.0 Safari/537.36 Error: Error Message: Test error Stack Trace: Error: Test error at SystemPromptVariables (http://localhost:3000/src/pages/Admin/SystemPromptVariables/index.jsx:36:9) at renderWithHooks (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:11568:26) at mountIndeterminateComponent (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:14946:21) at beginWork (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:15934:22) at beginWork$1 (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:19781:22) at performUnitOfWork (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:19226:20) at workLoopSync (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:19165:13) at renderRootSync (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:19144:15) at recoverFromConcurrentError (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:18764:28) at performConcurrentWorkOnRoot (http://localhost:3000/node_modules/.vite/deps/chunk-6FQJH6UM.js?v=c0da0ef1:18712:30) ``` ### Development View <img width="1904" height="1064" alt="image (1)" src="https://github.com/user-attachments/assets/3ce19d94-496f-4fdc-879e-f989069b7437" /> ### Production View <img width="1904" height="1064" alt="image (2)" src="https://github.com/user-attachments/assets/b5346ba4-cc08-4f42-a0fb-1cd2af95d761" /> ### Additional Information If you would like to see the error boundary at work just throw an error in a page component and then navigate to that page. <!-- Add any other context about the Pull Request here that was not captured above. --> ### Developer Validations <!-- All of the applicable items should be checked. --> - [x] I ran `yarn lint` from the root of the repo & committed changes - [x] Relevant documentation has been updated - [x] I have tested my code functionality - [x] Docker build succeeds locally --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-22 18:36:28 -05:00
yindo closed this issue 2026-02-22 18:36:28 -05:00
yindo changed title from [PR #4765] Implement Global Error Boundary to [PR #4765] [MERGED] Implement Global Error Boundary 2026-06-05 15:20:13 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#4760