Skip to content
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

Bugsnag loading fingerprint.browser.js instead of fingerprint.react-native.js #1676

Closed
adriaanbalt opened this issue Jan 26, 2022 · 3 comments

Comments

@adriaanbalt
Copy link

Environment

  • Bugsnag version: "@bugsnag/expo": "^7.16.0",
  • Browser framework version (if any):
    • "react-native": "0.64.3",
    • "react": "17.0.1",
  • Expo SDK Version: 43.0.2
  • Platforms(Android/iOS/web/all): web/iOS
  • Browser version (e.g. chrome, safari): Expo iOS simulator
  • Device (e.g. iphonex): iOS Simulator

Describe the bug

I was working in the iOS simulator, my project was working fine. I accidentally clicked "Run in web browser" inside my Metro Bundler browser window.

The below errors appeared

Error 1:

TypeError: undefined is not an object (evaluating 'navigator.userAgent.length')
- ... 9 more stack frames from framework internals

Screen Shot 2022-01-26 at 10 49 54 AM

Error 2:

Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:172:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError

Screen Shot 2022-01-26 at 12 42 54 PM

Attempts:


Attempt 1:

The package.json name and the app.json name are the same. I have restated my computer. Two metro bundlers are not running. I haven't edited AppRegistry.registerComponent or changed Expo's AppEntry.js.


Attempt 2:

I went back to an old commit, when I knew this was working, then ran the following commands:

$ rm -rf .expo .expo-shared yarn.lock node_modules
$ watchman watch-del-all 
$ rm -rf node_modules 
$ rm -fr $TMPDIR/haste-map-*
$ rm -rf $TMPDIR/metro-cache
$ yarn cache clean
$ yarn
$ yarn start

Even after doing this, the errors are still occurring.


Attempt 3:

navigator.userAgent would only be needed for the browser, not for an iOS or Android device. Which is why I think the issue I'm seeing is related to when I clicked "Run in web browser".

Notice that it says fingerprint.browser.js and AppEntry.bundle:192932:32 and loadModuleImplementation. I've a feeling that I may have not set something up for a web version of my app but after clicking that button something automagically changed.

I click on fingerprint.browser.js in the Call Stack and my editor opened a @bugsnag/cuid/lib/fingerprint.browser.js file, which has the navigator.userAgent code. 🤔 This comes from a bugsnag submodule located here

I re-initialized bugsnag: $ npx bugsnag-expo-cli init.

This had no change.

For some reason it appears that Bugsnag thinks I'm trying to load my app inside the browser when in fact I'm loading it within the iOS simulator. I looked into the package and it isn't obvious how this distinction is being made.


Thoughts

  • These two errors seem related. It appears that by triggering the web version of the app, the app and bugsnag have become confused on if I'm rendering in the browser or in a Native environment.
  • Something seems to be happening to the CUID lib but I can't exactly pinpoint what.

I'll continue debugging this until I find a solution but if anyone has any ideas I'm all ears. If I find a solution I'll post it here.

Further discussion can be found in this Expo forum post

@adriaanbalt
Copy link
Author

I removed "@bugsnag/expo": "^7.15.1", from my package JSON, remove all references to this package being loaded into my app, then $ yarn start and the app built as before.

To confirm, I re-added bugsnag. $yarn start and the same navigator.userAgent error as above appears.

Then I tried a simpler approach:
I kept @bugsnag/expo installed but I never call bugsnag.start() in my JavaScript. The app builds correctly in both iOS and web.

Appears to be an issue with how Expo and Bugsnag coordinate around which app variation is being executed. Possibly with Fingerprint but could be something else.

For now I cannot use Bugsnag until this is fixed :(

@johnkiely1
Copy link
Member

Hi @adriaanbalt.

I have tried to reproduce what you are seeing using a brand new expo 43 project and setting the versions of the libraries to the same as you reported. However it appears to be working for me in that clicking on the run in web browser has no effect on the iOS simulator and no errors are thrown. Would you be able to share a simple reproduction example project that demonstrates this and I'd be happy to investigate further.

You can send that to us at support@bugsnag.com
Thanks.

@johnkiely1 johnkiely1 added the awaiting feedback Awaiting a response from a customer. Will be automatically closed after approximately 2 weeks. label Jan 28, 2022
@johnkiely1
Copy link
Member

Hi @adriaanbalt, I'm going to close this as we have been unable to reproduce what you are seeing and have no real way to progress this further. If you can provide us with a reproduction example we will be happy to reopen and continue investigations. Thanks

@johnkiely1 johnkiely1 removed the awaiting feedback Awaiting a response from a customer. Will be automatically closed after approximately 2 weeks. label Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants