-
Notifications
You must be signed in to change notification settings - Fork 251
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
[PLAT-5357] fix(react-native): Ensure plugin usage does not crash debugger #1250
Conversation
createClientAsync(opts).then(client => { | ||
initialised = true | ||
Bugsnag._client = client | ||
return Reflect.apply(target, thisArg, args) |
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.
Should this still be applying to Bugsnag._client
if it has initialised?
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.
Yeah it has to carry being functional because plugins created and obtained synchronously still have a reference to that stubbed client. If we stopped apply()
ing and no-op'ing, it could fail due to a plugin expecting it to return something.
stubClient[m] = new Proxy(stubClient[m], { | ||
apply: (target, thisArg, args) => { | ||
if (!initialised) { | ||
console.log(`Synchronous call to Bugsnag.${m}()`) |
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.
I changed this to a log rather than a warn, so that it doesn't pop up in the app's yellowbox UI.
Goal
When run in the debugger, the React Native notifier starts asynchronously due to synchronous calls to native not being available in the debugging environment.
The existing workaround involved creating a no-op stubbed client interface, which covered most use cases, but not plugins where the return value of
Bugsnag.getPlugin('<name>')
was required, resulting in the following bugs: #1143 #1112.Design
The new solution is to create an actual
Client
instance so that plugins can be used in the short delay before the notifier starts properly.Changeset
Testing
The changes were manually tested in the remote debugger on an app using React Navigation.