Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Default route doesn't check request protocol, picks up chrome-extension:// #171

Closed
JohnPhilipPearson opened this issue Aug 15, 2016 · 8 comments

Comments

@JohnPhilipPearson
Copy link

error with extensions

Example given during NYC Roadshow

sw-toolbox.js:18 Uncaught (in promise) TypeError: Request scheme 'chrome-extension' is unsupported(…)(anonymous function) @ sw-toolbox.js:18

@themojilla
Copy link

i have this problem too

@jeffposnick
Copy link
Contributor

My guess is that this is related to default routes, as the logic currently looks like:

if (handler) {
  event.respondWith(handler(event.request));
} else if (router.default && event.request.method === 'GET') {
  event.respondWith(router.default(event.request));
}

That else if clause should probably check the protocol of event.request to confirm that it's https: as an additional condition.

@JohnPhilipPearson, can you confirm that you're using a default route?

@JohnPhilipPearson
Copy link
Author

That was the case

@JohnPhilipPearson
Copy link
Author

That was the case using a default route

@jeffposnick jeffposnick changed the title error with extensions Default route doesn't check request protocol, picks up chrome-extension:// Sep 16, 2016
@Splaktar
Copy link

What effect does this exception have other than an error in the console? Does this break caching or anything else? Or is this completely harmless?

Asking, since we are seeing it on our conference site and having a lot of SW related problems. Additionally asking since this isn't in a usable bower release yet.

@jeffposnick
Copy link
Contributor

The fix just went out with the 3.4.0 release.

I'd recommend upgrading if you have users with specific Chrome extensions installed and have bumped up against this bug. It's unlikely that it's caused extensive service worker-related issues, though, so please let us know (along with steps for reproductions, in a new issue) if you're seeing unexpected behavior.

@TimeBandit
Copy link

Say this today with a localhost server, went away when I opened the page in incognito mode. The chrome extension causing it is the 'Stayfocused' extension.

@FAHAD-guma
Copy link

const cacheName = 'v1';

// Call Install Event
self.addEventListener('install', e =>{
console.log('Service Worker: Installed');

});

// Call Activate Event
self.addEventListener('activate', e =>{
console.log('Service Worker: Activated');
//Remove unwanted caches
e.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames.map(cache => {
if(cache !== cacheName){
console.log('Sercice Worker: Clearing Old Cache');
return caches.delete(cache);
}
})
)
})
);
});

//event.request.headers.delete("x-chrome-uma-enabled");
//event.request.headers.delete("x-client-data");
//Call Fetch Event
self.addEventListener('fetch', e => {
console.log('Service Worker: Fetching');
e.respondWith(
fetch(e.request)
.then(res => {
//Make copy/clone of response
const resClone = res.clone();
//Open cache
caches
.open(cacheName)
.then(cache => {
//Add response to cache
cache.put(e.request, resClone);
});
return res;
}).catch(err => caches.match(e.request).then(res => res))
);
});

thats my code and am getting similar error and its complaining line ---cache.put(e.request, resClone);---
Any help is highly welcom

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants