Failed to load Stripe.js
See original GitHub issueSummary
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:
- Created 3 years ago
- Comments:31 (12 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 theiruseAuth0
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.
I’m seeing a large number of these errors but all on iOS / macOS safari 13.0.5