You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const loadPromise = new Promise<void>((resolve, reject) => {
el.addEventListener('load', function () {
resolve()
if (onLoad) {
onLoad.call(this)
}
})
el.addEventListener('error', function () {
reject()
if (onError) {
onError()
}
})
})
reject is called but loadPromise never has an error handler attached unless you create two tags for the same script which will do ScriptCache.get(src).then(onLoad, onError)
Expected Behavior
No unhandled rejection error for errors and pass the real error to the onError
To Reproduce
<Script
src="https://somebrokenlink.doesntexist"
strategy="lazyOnload"
onLoad={() => {
console.log('success');
}}
onLoad={(e) => {
console.log('error');
console.log(e); // this doesn't exist either
}}
/>
The text was updated successfully, but these errors were encountered:
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
vercel
locked as resolved and limited conversation to collaborators
Jan 28, 2022
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of Next.js are you using?
11
What version of Node.js are you using?
12.14.1
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
next start
Describe the Bug
Loading any script which fails to load generates an unhandled rejection error "Uncaught (in promise) undefined"
This is due to this code
https://github.com/vercel/next.js/blob/canary/packages/next/client/script.tsx#L58
reject is called but loadPromise never has an error handler attached unless you create two tags for the same script which will do
ScriptCache.get(src).then(onLoad, onError)
Expected Behavior
No unhandled rejection error for errors and pass the real error to the onError
To Reproduce
The text was updated successfully, but these errors were encountered: