You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I forget to start the local server to serve my build, but visit it in the browser anyway, the old sw can still serve the old assets, and I may not notice. I thought part of the intention of checkValidServiceWorker() was to cover this scenario, but seems it doesn't.
something like this will cover that:
exportfunctionregister(){if(process.env.NODE_ENV==="production"&&"serviceWorker"innavigator){constswUrl=`${process.env.PUBLIC_URL}/service-worker.js`;window.addEventListener("load",async()=>{if(isLocalhost)awaitvalidateLocalServer(swUrl);registerSW(swUrl);});}}asyncfunctionvalidateLocalServer(swUrl: string){try{constres=awaitfetch(swUrl,{headers: {"Service-Worker": "script"}});// this throws if server isn't runningif(res.status===404)thrownewError("404");}catch(err){alert(`Local server is not running, or running but no sw found. \n${err.message}`);returnPromise.reject();}}asyncfunctionregisterSW(swUrl: string){//...}
The text was updated successfully, but these errors were encountered:
If I forget to start the local server to serve my build, but visit it in the browser anyway, the old sw can still serve the old assets, and I may not notice. I thought part of the intention of
checkValidServiceWorker()
was to cover this scenario, but seems it doesn't.something like this will cover that:
The text was updated successfully, but these errors were encountered: