-
Notifications
You must be signed in to change notification settings - Fork 58
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
Add error boundary components and exception logging #6655
Merged
Merged
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
76eabd4
Update Gutenberg ref
fluiddot b753732
Add error logging setup
fluiddot 24f4aa0
Update Gutenberg ref
fluiddot ae8851c
Add bundle and source map files to gitignore
fluiddot 4556a29
Include source map when generating the xcframework
fluiddot 2afe0f4
Update Gutenberg ref
fluiddot 6fd1862
Upload source map artifact during JS bundle generation
fluiddot b3db684
Update Gutenberg ref
fluiddot ecb8b0a
Trigger default error handler after sending an unhandled JS exception
fluiddot 19d9b7f
Call default error handler only after the exception is sent
fluiddot d883dd2
Update Gutenberg ref
fluiddot d0b3119
Merge branch 'trunk' into add/error-boundary
fluiddot 6a50374
Generate composed source map after creating bundles
fluiddot 815fd89
Update Gutenberg ref
fluiddot 61ba344
Mark exceptions detected by error handler as unhandled
fluiddot 6bd6d87
Update Gutenberg ref
fluiddot 2640b6d
Limit exception logging to fatal errors
fluiddot 3785095
Update Gutenberg ref
fluiddot 0003382
Update Gutenberg ref
fluiddot 556f6ad
Update Gutenberg ref
fluiddot cdf9bfd
Update Gutenberg ref
fluiddot 6fdcd61
Merge branch 'trunk' into add/error-boundary
fluiddot f1698d6
Include source map to Android assets
fluiddot c06df89
Update Gutenberg ref
fluiddot 32e5e93
Update Gutenberg ref
fluiddot a88a073
Update Gutenberg ref
fluiddot db21bd3
Merge branch 'trunk' into add/error-boundary
fluiddot 3b6fab2
build: Update Gutenberg ref
fluiddot 585cc17
Update release notes
fluiddot 39749cc
build: Update Gutenberg ref
fluiddot 46d7600
Update Gutenberg ref
fluiddot 1e665f9
Update Gutenberg ref with merge commit
fluiddot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { logException } from '@wordpress/react-native-bridge'; | ||
|
||
// Setting Error handler to send exceptions. This implementation is based on Sentry React Native SDK: | ||
// https://github.com/getsentry/sentry-react-native/blob/adfb66f16438dfd98f280307844778c7291b584b/src/js/integrations/reactnativeerrorhandlers.ts#L187-L262 | ||
export default () => { | ||
const errorUtils = global.ErrorUtils; | ||
const defaultHandler = | ||
errorUtils.getGlobalHandler && errorUtils.getGlobalHandler(); | ||
|
||
let handlingFatal = false; | ||
errorUtils.setGlobalHandler( ( error, isFatal ) => { | ||
// For now, only fatal errors are logged | ||
if ( ! isFatal ) { | ||
defaultHandler( error, isFatal ); | ||
return; | ||
} | ||
|
||
// On production, we only allow logging a single fatal error. | ||
// This prevents sending extra exceptions derived from the original error. | ||
if ( ! __DEV__ ) { | ||
if ( handlingFatal ) { | ||
// eslint-disable-next-line no-console | ||
console.warn( | ||
'Encountered multiple fatals in a row. The latest:', | ||
error | ||
); | ||
return; | ||
} | ||
handlingFatal = true; | ||
} | ||
|
||
logException( | ||
error, | ||
{ isHandled: false, handledBy: 'Global Error Handler' }, | ||
() => { | ||
// Wait for the exception to be sent to host app | ||
defaultHandler( error, isFatal ); | ||
} | ||
); | ||
} ); | ||
}; |
This file contains 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
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.
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.
The composed source map is now generated as part of the
bundle
npm command.