Open n1ywb opened 7 years ago
It might have something to do with this using the wrong BASE_URI https://github.com/PolymerElements/app-storage/blob/master/app-indexeddb-mirror/common-worker.html#L23
I think this is indeed a bug in https://github.com/PolymerElements/app-storage/blob/master/app-indexeddb-mirror/common-worker.html#L23
I added a rewrite rule to my firebase.json and it seems to have worked around this issue in my app
{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "./build/bundled/",
"rewrites": [
{
"source": "/src/common-worker-scope.js",
"destination": "/bower_components/app-storage/app-indexeddb-mirror/common-worker-scope.js"
},
{
"source": "**/*",
"destination": "/index.html"
}
]
}
}
still not sure if this fixes offline support
Nope, didn't fix offline, it just gets stuck on that request
I added some things to my sw-prechache config
+ '/bower_components/app-storage/app-indexeddb-mirror/app-indexeddb-mirror-worker.js',
+ '/bower_components/app-storage/app-indexeddb-mirror/common-worker-scope.js',
+ '/bower_components/app-storage/app-indexeddb-mirror/common-worker.html'
now it gets past that request and actually loads data from indexeddb when offline so that's a big improvement; only after a long delay though
I also hacked in this to common-worker.html
var BASE_URI = "/bower_components/app-storage/app-indexeddb-mirror";
This didn't work
var BASE_URI = "/bower_components/app-storage/app-indexeddb-mirror";
but THIS did
var WORKER_SCOPE_URL =
Polymer.ResolveUrl.resolveUrl('/bower_components/app-storage/app-indexeddb-mirror/common-worker-scope.js', BASE_URI);
Still no offline joy, until I think I found the last piece of the offline puzzle; common-worker does this thing where it passes the url to the real worker as a URL argument with ? and that confuses the service worker and bypasses the pre-cache
Found the fix here https://github.com/GoogleChrome/sw-precache#ignoreurlparametersmatching-arrayregex
put
ignoreUrlParametersMatching: [
/app-indexeddb-mirror/
],
into sw-precache-config.js
@abdonrd Looks related to Polymer/polymer-build#22
I also opened https://github.com/PolymerElements/app-storage/issues/78
I was trying to get the app to work offline on my phone without much luck; I fired up chrome remote debugging and sure enough there is an error on the js console
if we flip over to the network pane and look at the offending request I note that although a .js file was requested, the server has responded with text/html content; indeed on the preview pane I see that it is index.html
You can actually test this from the command line using this curl command; you should get JS but you get HTML
I hypothosise this is caused by firebase hosting rewriting the URL to index.html. maybe because of the rewrite rules in firebase.json
alternatively maybe the service worker config needs to treat this request differently?
need to figure out how to get firebase to NOT rewrite that URl