Shopify / shopify-app-bridge

https://shopify.dev/docs/api/app-bridge
88 stars 9 forks source link

WebVitals init fails in app bridge init, killing the init process #145

Closed njokipal closed 2 years ago

njokipal commented 2 years ago

Describe the bug

Using 3.3.x versions of the @shopify/app-bridge, calling createApp() will throw TypeError: web_vitals_1.onLCP is not a function killing the app bridge init as we have the call inside a try...catch where catching an error will just display an error state.

App is created using create-react with manually added Shopify deps

To Reproduce

Steps to reproduce the behaviour:

  1. Have @shopify/app-bridge at 3.3.0,
  2. Launch the app $ npm run start
  3. Have createApp() inside try...catch

Expected behaviour

If WebVitals isn't essential, no exceptions were thrown if the package cannot for some reason initialise it's internals. Just report a problem and continue.

Contextual information

Packages and versions

List the relevant packages you’re using, and their versions. For example:

WebVitals is additionally registered by our own app. It makes no difference, if it is included or not to the error case

Platform

Additional context

Node.js 16, React app created using create-react, manually added Shopify deps

charlesdobson commented 2 years ago

Hi @njokipal!

Could you please try this out with v3.3.2 and let me know if you're still experiencing an issue?

njokipal commented 2 years ago

Excellent, 3.3.2 actually works. I'm fairly certain I tried all the 3.3.x versions available before reporting the issue, but it might be that my node_modules or the React developer mode just didn't actually load the proper version.

Closing. Thanks @charlesdobson

charlesdobson commented 2 years ago

Nope, you were correct! I made a quick fix and published it in 3.3.2. Thanks for reporting the issue!

mhaseebullah92 commented 1 year ago

@charlesdobson facing this issue on my local, using ngrok to debug the Shopify app locally. I tried the above versions but it's not working.

@shopify/app-bridge-react @ ^3.7.7 @shopify/polaris @ ^10.49.1 web-vitals @ ^2.1.4 react @ ^18.2.0

NodeJS @ v18.16.0 OS: Windows 11

Error on the console: App-Bridge failed to initialize web-vitals TypeError: web_vitals_1.onLCP is not a function

rahul-adnabu commented 1 year ago

@mhaseebullah92 i am also facing the same issue, did you found any solution for it?

mhaseebullah92 commented 1 year ago

@rahul-adnabu now I am using @shopify/app-bridge-react @ 3.1.0 because this version is not dependent on web-vitals. but still facing the same issue on the latest version. This issue is closed now I am creating a new issue for it.

rahul-adnabu commented 1 year ago

@mhaseebullah92 isn't web vitals necessary for shopiify to track lcp, cls?

mhaseebullah92 commented 1 year ago

I opened a new bug https://github.com/Shopify/shopify-app-bridge/issues/206 for this issue.

mark-barrett commented 1 year ago

Also having this issue. The app was working yesterday during development, but without changing anything, we are getting the same.

zainakram99 commented 1 year ago

when i try to run my shopify app , i get this error in the console " TypeError: o.onLCP is not a function" , i try the google search but still not able to find the solution , plz help me if you can.

BusyginArtem commented 8 months ago

I'm having the same issue. Did anybody solve this issue?