fix(error-page): render gracefully when panel prop is missing - #5
Merged
Conversation
The error page assumed `panel` was always provided, but a 500 thrown outside the panel middleware stack (or before `RenderMonorailErrorPages` injects the panel data) arrives with `panel === undefined`. The page then crashed at `panel.translations`, masking the original server error with a React render error. Make `panel` optional, fall back to safe defaults, and render a standalone centered layout when the panel shell can't be used.
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.
Summary
The error page (
resources/js/pages/error.tsx) assumedpanelwas always provided. When a 500 is thrown outside the panel middleware stack — or beforeRenderMonorailErrorPageshas had a chance to inject panel data — the page receivespanel === undefinedand crashes at:```ts
const __ = create__(panel.translations ?? {});
// ^^^^^ TypeError: Cannot read properties of undefined
```
The React render error then masks the actual server error, making the underlying 500 hard to diagnose.
Fix
panelprop optional.panel?.translationsandpanel?.pathwith sane fallbacks.panelis missing, skipPanelShell(which strictly requires it) and render a centered standalone layout so the status, title, and message still reach the user.Reproduction
/opportunities).panelprop.TypeError: Cannot read properties of undefined (reading 'translations')./.Test plan
/adminand confirm the error page renders/adminand confirm panel shell still wraps the error (no regression)