ipfs/service-worker-gateway

bug: path request to subdomain redirect results in logged "event.respondWith" error

SgtPooki opened this issue · 1 comments

When redirecting from a path domain to a subdomain, there is some async operation occurring that the service worker fetch handler isn't managing well and we're getting this error prior to the redirect:

Uncaught (in promise) DOMException: Failed to execute 'respondWith' on 'FetchEvent': The event handler is already finished.
    at http://localhost:3000/ipfs-sw-sw.js:917:15
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (http://localhost:3000/ipfs-sw-sw.js:760:103)
    at _next (http://localhost:3000/ipfs-sw-sw.js:761:194)
    at http://localhost:3000/ipfs-sw-sw.js:761:364
    at new Promise (<anonymous>)
    at http://localhost:3000/ipfs-sw-sw.js:761:97
    at http://localhost:3000/ipfs-sw-sw.js:921:20

note that you need preserve logs enabled for the console to see the error. this isn't a priority, because I believe any parallel requests the page kicks off on first load are interrupted when the redirect happens.

However, our code should be robust enough to not throw this error at all

note: I think we should be waiting to call event.respondWith instead of encapsulating deep promises inside of it. Otherwise, we can't capture this error which will throw if a request is aborted while in progress