Repository navigation
fix(ui): add a top-level renderer error boundary - #57
Merged
Merged
Conversation
Any render-phase exception unmounted the whole React tree and left a blank window with no on-screen clue. The "Add to Note" crash was the latest example of that failure mode. Wrap <App /> in an error boundary that keeps the error on screen, logs the original error and component stack, and offers a reload.
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.
What does this PR do?
Adds a top-level React error boundary so a render error can no longer leave the app as a blank window.
Why?
The renderer had no error boundary. Any render-phase exception made React unmount the whole tree, so the user got a white window with nothing to act on. The "Add to Note" crash (
TypeError: ... reading 'getMarkdown'inNoteEditor) was the latest instance of this failure mode; the underlying crash is fixed separately, but the app should not be able to disappear like that again.Related issue
None.
What changed?
AppErrorBoundary(src/renderer/src/components/common/AppErrorBoundary.tsx): catches render errors, logs the error and component stack viacomponentDidCatch, shows the error message and a Reload button.main.tsxwraps<App />in the boundary.errorTitle,errorDescriptionandreloadto thecommonnamespace (en-US, zh-CN).The boundary uses the
i18ninstance directly instead ofuseTranslation, because it must be able to render outside a React provider.How was this tested?
Appthrow during render, then launchednpm run devand inspected the window over Electron CDP:Something went wrong/An unexpected error occurred. Reload to continue./ the error message /Reload,[AppErrorBoundary] Uncaught render error: Error: ...,npm run typecheck:webpasses.npm run check:designpasses (no token/design violations).npx prettier --checkon the touched files passes.Screenshots / recordings
Not captured.
Checklist
npm run typecheckpasses.npm run buildpasses.Desktop / build changes