-
Notifications
You must be signed in to change notification settings - Fork 35
feat(packages/sui-react-initial-props): add error handling and logging to getInitialProps #1961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…g to getInitialProps
BREAKING CHANGES: load page not receiving contextfactory anymore
|
|
||
| logger?.error?.(message, error as Error) | ||
|
|
||
| return {error: error instanceof Error ? error.message : message} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just throw an error so we do not change the previous behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, maybe it's better to log the error and then throw it instead of returning a new object, I'm doing some tests locally before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
Add error handling and logging support to server-side getInitialProps
Changes
getInitialPropsexecution in try-catch block to prevent application crashesloggerparameter toloadPagefunction for error reportingLoggertype witherrormethod signature🚨 BREAKING CHANGES
contextFactoryparamMotivation
When
getInitialPropsthrows an error on the server, it can crash the entire SSR process. This change adds resilience by catching errors and optionally logging them for observability.Usage