WebThingsIO / gateway

WebThings Gateway - a self-hosted web application for monitoring and controlling a building over the web
http://webthings.io/gateway
Mozilla Public License 2.0
2.62k stars 339 forks source link

After update to 0.10.0, my phone's browser is getting a blank add-ons pane, due to using old/stale JS & CSS URIs (?) #2289

Closed dholbert closed 4 years ago

dholbert commented 5 years ago

Ever since receiving the 0.10.0 gateway update yesterday (I think), my phone's view of my Gateway web-interface has been unable to list any add-ons. The add-ons list just shows up as blank, and so does its "+" view (to discover new add-ons) -- they both incorrectly behave as if no add-ons exist or are available at all.

I think this is because my phone is stuck with a bogus/stale URI for its JS/CSS bundles, for some reason (perhaps a stale service worker?). At least: when I load the add-ons page on my phone, I see these errors:

Failed to parse add-on settings: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data 15 d7178b24e398ac1a4db0-app.js:48095:21
    fetchInstalledAddonsDeferred https://eagle.mozilla-iot.org/bundle/d7178b24e398ac1a4db0-app.js:48095
    notify https://eagle.mozilla-iot.org/bundle/d7178b24e398ac1a4db0-app.js:12019
    flush https://eagle.mozilla-iot.org/bundle/d7178b24e398ac1a4db0-app.js:8983
TypeError: "responses is undefined"
    fetchAvailableAddonsDeferred https://eagle.mozilla-iot.org/bundle/d7178b24e398ac1a4db0-app.js:48197
    notify https://eagle.mozilla-iot.org/bundle/d7178b24e398ac1a4db0-app.js:12019
    flush https://eagle.mozilla-iot.org/bundle/d7178b24e398ac1a4db0-app.js:8983
d7178b24e398ac1a4db0-app.js:12019:22
    notify https://eagle.mozilla-iot.org/bundle/d7178b24e398ac1a4db0-app.js:12019
    flush https://eagle.mozilla-iot.org/bundle/d7178b24e398ac1a4db0-app.js:8983
Source map error: Error: JSON.parse: unexpected character at line 1 column 1 of the JSON data
Resource URL: https://eagle.mozilla-iot.org/bundle/d7178b24e398ac1a4db0-style.css
Source Map URL: d7178b24e398ac1a4db0-style.css.map

(Notice the hash d7178b24e398ac1a4db0 in the URIs there -- I believe those .css/.js files no longer exist, which is why we're having trouble loading them.)

If I try accessing the gateway from another browser, then everything is fine, and in devtools I can see it loading different bundle URIs with a different hex ID, 9ba0b98a02b85688ed96: https://eagle.mozilla-iot.org/bundle/9ba0b98a02b85688ed96-app.js https://eagle.mozilla-iot.org/bundle/9ba0b98a02b85688ed96-style.css (I can load ^^ these js/css URIs directly just fine right now, so they look like the right ones.)

So I think my phone browser is stuck with the old URIs in some local cache / service-worker or something, and as a result it's (currently) unable to show me the gateway add-ons settings page.

Is this a known issue & is there anything we can do to prevent this in the future?

dholbert commented 5 years ago

CC @mrstegeman

dholbert commented 5 years ago

BTW the browser that's affected by this issue is Firefox Beta on my Android phone (which reports itself as version 68.3b4); but I don't think it's anything special about that browser, aside from the fact that it's what I had been using to view the gateway before the 0.10.0 update and so it's got some stale info cached.

B0IIE commented 5 years ago

I had the same issue on FF 70 on my PC. A reload with ctrl + f5 solved the problem. After that it surprisingly also worked on my phone with firefox mobile

dholbert commented 5 years ago

Sadly, that didn't do the trick for me. (In my case, my phone has the only browser affected by this issue, and hard-reloading on other browsers doesn't seem to help.)

dholbert commented 5 years ago

FWIW: I just worked around this locally by (in Firefox Beta on Android, aka Fennec): Settings|Clear Private Data, and I checked "cache" and "offline website data" to be cleared. ("cache" wasn't sufficient on its own -- I tried that earlier. So it's probably just "clear...offline website data" that I needed here.)

This logged me out of my gateway; and after I logged in again, I was able to see the Add-ons page just fine. (Maybe really a logout + login would have been sufficient to work around this, without any "Clear Private Data" action being needed?)