diff --git a/src/components/data.ts b/src/components/data.ts index 5b2dca1503ee4757b62944d2df4f3d2133540f59..c2db5c6bb3bf6b1ab8935dc4493841acc2477cfb 100644 --- a/src/components/data.ts +++ b/src/components/data.ts @@ -116,9 +116,13 @@ async function fetchJsonp (opts: GetDataOpts): Promise<Readonly<unknown>> { // For testing in parcel it works better to have a subpath that we can // exclude from parcel. : `/${process.env.BUILD_PREFIX}${opts.path}` - if (document.querySelector(`script[src="${url}"]`) !== null) { + const existingScript = document.querySelector(`script[src="${url}"]`) + if (existingScript !== null) { // already being fetched, append to the list of existing waiters registerJsonpWaiter(opts.key, resolve) + existingScript.addEventListener('error', () => { + reject(new Error(`No character data available for ${opts.key}`)) + }) } else { // no fetch in flight, inject a new script tag const script = document.createElement('script')