RESOLVED DUPLICATE of bug 245788245866
Safari 16 issuing requests twice with navigationPreload enabled
https://bugs.webkit.org/show_bug.cgi?id=245866
Summary Safari 16 issuing requests twice with navigationPreload enabled
Alex
Reported 2022-09-30 00:16:56 PDT
When I using navigationPreload.enable(), Safari 16.x on macOs and all browser on ios16.x make two requests Here is my code: const uri = 'https://uri'; self.addEventListener('activate', event => { event.waitUntil((async () => { if (self.registration.navigationPreload) { await self.registration.navigationPreload.enable(); } })()); }); self.addEventListener('fetch', (event) => { const request = event.request; if (request.mode === 'navigate' && request.destination !== 'iframe') { event.respondWith((async () => { try { return await event.preloadResponse || await fetch(request); } catch (e) { const response = await fetch(uri); if (response.ok) { const text = await response.text(); const body = decode(text); return new Response(body, { headers: { 'Content-Type': 'text/html' } }); } } })()); } }); function decode(str) { return decodeURIComponent( some code ); }
Attachments
Alex
Comment 1 2022-09-30 08:02:50 PDT
this is minimal reproducer self.addEventListener('activate', event => { event.waitUntil((async () => { if (self.registration.navigationPreload) { await self.registration.navigationPreload.enable(); } })()); }); self.addEventListener('fetch', (event) => { const request = event.request; event.respondWith((async () => { return await event.preloadResponse || await fetch(request); })()); });
Radar WebKit Bug Importer
Comment 2 2022-09-30 15:06:33 PDT
youenn fablet
Comment 3 2022-10-03 01:25:29 PDT
Thanks for the report. I believe this was fixed in https://bugs.webkit.org/show_bug.cgi?id=245788.
youenn fablet
Comment 4 2022-10-03 01:25:39 PDT
*** This bug has been marked as a duplicate of bug 245788 ***
Note You need to log in before you can comment on or make changes to this bug.