'A ServiceWorker intercepted the request and encountered an unexpected error
I recently implemented Angular service workers in my web app and when I reload my app in some routes, I get this error and the site stucks in app-shell
:
Failed to load ‘https://<my-test-domain>/runtime.4c3f9e771b5d653d.js’. A ServiceWorker intercepted the request and encountered an unexpected error.
For example when I reload on https://<my-test-domain>/landing
it works fine.
But when I reload on https://<my-test-domain>/chat/123456
the error will show in console. (123456 is a p2p thread id in chat section)
My ngsw-config.json
:
{
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
"index": "/index.html",
"appData": {
"version": "3.2.3",
"changeList": [],
"force": false
},
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html",
"/manifest.json",
"/*.css",
"/*.js"
]
}
},
{
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**",
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
]
}
}
]
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|