Closed jankapunkt closed 1 month ago
I did find an easy solution for this error which was also a common solution for many other Service Workers where others were reporting this error.
Inside the fetch
event listener:
self.addEventListener('fetch', (event) => {});
The easiest approach was to inspect each event.request.url
and filter out the chrome-extention://
urls by accepting only http
& https
urls.
// inspect each event request url in the console
console.log("event request startsWith & url:", event.request.url.startsWith('http'), event.request.url);
To do this we just wrap the main code inside the fetch
event listener with a conditional statement
if (event.request.url.startsWith('http')){
// only process http & https requests, prevents chrome-extention errors
const requestToFetch = event.request.clone();
event.respondWith();
}
This worked nicely, so I went ahead and created a PR for it here: https://github.com/NitroBAY/meteor-service-worker/pull/24
@jankapunkt is it working for you ?
Merged
I am using the Meteor Devtools Evolved Extension and the sw always fails when the extension is loaded:
event.request
ischrome-extension://ibniinmoafhgbifjojidlagmggecmpgf/build/inject.js
and I getShould I add a test on the request to contain
http(s)://
? Potential fix would be