From d8af41d6903e09e0b779c8199aa02fb1fec912cb Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Thu, 16 Feb 2017 05:43:27 +0530 Subject: [PATCH] Add a way to disable running service workers. (#1167) --- lib/router/router.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/router/router.js b/lib/router/router.js index 74706f78..76bd8600 100644 --- a/lib/router/router.js +++ b/lib/router/router.js @@ -10,6 +10,16 @@ import { loadGetInitialProps, getLocationOrigin } from '../utils' // Add "fetch" polyfill for older browsers if (typeof window !== 'undefined') { require('whatwg-fetch') + // Unregister if there's an exisiting service worker. + // This is because we ship a service worker in previous version. + // We don't use it and having a already running worker might cause issues. + // (We can remove this in future releases) + navigator.serviceWorker.getRegistrations() + .then((registrations) => { + for (let registration of registrations) { + registration.unregister() + } + }) } export default class Router extends EventEmitter {