Describe the bug
In a recently spotted Sentry issue, we've seen the following exception thrown in this line of the inserter menu:
Unhandled JS Exception: TypeError: undefined is not an object (evaluating 'Y.items')
Unfortunately, this exception doesn't give any clue about what happened as it's not expected that a call to the useSelect hook returns an undefined object. Investigating further, we noticed that exceptions thrown within the mapSelect function passed in the hook caused the same error but didn't include the stacktrace of the exception itself.
The reason for this is that the useSelect hook executes the mapSelect function in a try-catch block (reference), so exceptions are not reported upstream, only its side-effect in the shape of an undefined object and an error log in the RN console (reference).
This issue is making harder the task of debugging errors/crashes and it might be covering other potential issues, so it would be great to figure out a way to report them to Sentry.
To Reproduce
- Add the following code
throw Error( 'error test' ); into this line.
- Open the app and connect it with the Metro server.
- Open a post/page.
- Tap on the ➕ button to open the inserter menu.
- Observe that the error
undefined is not an object is shown.
- Observe in the RN console that the error
An error occurred while running 'mapSelect': error test is logged.
Expected behavior
Exceptions thrown in the mapSelect function of useSelect hooks should be reported to Sentry.
Screenshots
N/A
Smartphone (please complete the following information):
- Device: iPhone 12 Pro Max
- OS: iOS 14.5
- Version 18.2
Additional context
N/A
Describe the bug
In a recently spotted Sentry issue, we've seen the following exception thrown in this line of the inserter menu:
Unfortunately, this exception doesn't give any clue about what happened as it's not expected that a call to the
useSelecthook returns anundefinedobject. Investigating further, we noticed that exceptions thrown within themapSelectfunction passed in the hook caused the same error but didn't include the stacktrace of the exception itself.The reason for this is that the
useSelecthook executes themapSelectfunction in atry-catchblock (reference), so exceptions are not reported upstream, only its side-effect in the shape of anundefinedobject and an error log in the RN console (reference).This issue is making harder the task of debugging errors/crashes and it might be covering other potential issues, so it would be great to figure out a way to report them to Sentry.
To Reproduce
throw Error( 'error test' );into this line.undefined is not an objectis shown.An error occurred while running 'mapSelect': error testis logged.Expected behavior
Exceptions thrown in the
mapSelectfunction ofuseSelecthooks should be reported to Sentry.Screenshots
N/A
Smartphone (please complete the following information):
Additional context
N/A