question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to load Stripe.js

See original GitHub issue

Summary

Some of my users are getting an error thrown Failed to load Stripe.js Sadly, I can’t reproduce and I don’t have more details. My page is working perfectly fine for me and some of my colleagues.

I have js.stripe.com/v3 loaded in my head tag And loadStripe is correctly executed only once.

Here is my code:

import { useState, useEffect } from 'react'
import { loadStripe } from '@stripe/stripe-js'

const StripeJSProvider = ({ children }) => {
  const [stripe, setStripe] = useState(false)

  useEffect(() => {
    if (!stripe) {
      setStripe(loadStripe(process.env.STRIPE_KEY))
    }
  }, [stripe])

  return children({ stripe })
}

export default StripeJSProvider

And then later:

<StripeJSProvider>
      {({ stripe }) =>
        stripe ? (
          <Elements stripe={stripe}>
            <MyComponent... />
          </Elements>
        ) : (
          <PageLoader />
        )
      }
    </StripeJSProvider>

Other information

According to sentry report, it looks like it’s happening only on Firefox.

Thanks for your help.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:31 (12 by maintainers)

github_iconTop GitHub Comments

15reactions
langercommented, Mar 5, 2021

For anyone who may still be coming across this error, we were mystified by this ourselves, and witnessing it only affecting Safari and Mobile Safari users. It turns out the errors were not adversely affecting our users at all — what was happening was, we use auth0 for our identity provider, and lean on the loginWithRedirect() method from their useAuth0 React hook, and what was happening was a user was being redirected before the stripe.js asset had completed loading, which was triggering the event listener here to fire. I can easily reproduce this by selecting “Clear History…” in Safari and visiting our site, and each time I do it the error is fired.

cc @hofman-stripe, this may be of interest to you.

6reactions
esetnikcommented, May 1, 2020

I’m seeing a large number of these errors but all on iOS / macOS safari 13.0.5

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to load Stripe.js at HTMLScriptElement.<anonymous>
I tried using the stripe cdn src='https://js.stripe.com/v3/' in my pug template and that didn't work form me, so I used the npm module....
Read more >
element.on('loaderror',handler) - Stripe JS Reference
Triggered when the Element fails to load. This event is only emitted from the payment , linkAuthentication , and address Elements.
Read more >
Including Stripe.js
Include the Stripe.js script on each page of your site—it should always be loaded directly from https://js.stripe.com , rather than included in a...
Read more >
Stripe JS Reference
Triggered when the Element fails to load. This event is only emitted from the payment , linkAuthentication , and address Elements. Method parameters ......
Read more >
Error codes | Stripe Documentation
Learn more about error codes and how to resolve them. Reviewing errors. Stripe logs every successful or failed API request your integration makes....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found