The crazy continues...
Chrome has a 5MB limit for the size of the app cache. If we go over the limit (say we're including public/ in the app cache so those resources will be available offline, but we put too much stuff in there), loading the app cache fails and the application gets sent an app cache "error" event.
Now what happens? Assuming the app is already cached (this isn't the very first time we've loaded the app), the browser continues to use the old cached code.
Which may or may not be OK. The default assumption in Meteor is that it's not OK to use old code on the client with new code on the server. Which the programmer can change by setting the SERVER_ID (to say when a code change is a "minor" code change that doesn't need to force a reload).
Suppose we've made a "major" code change (there's no point in having old client code talk to the new server code; methods have been renamed or collections have a different structure or whatever). Now we've got an app which doesn't work offline because we violated a browser limitation, but it also now doesn't work online either because it's using old cached client code.
So... ideas... suppose the client were to detect this condition and set a "nocache" cookie which causes the server to deliver a plain web app (like standard Meteor does today) without an app cache. so then the app would at least be able to work online while the offline problem was being fixed. (I.e., it's nice to be able to work offline when we can, but don't cause on other working online application to break).
Ah, but the application will get an app cache "error" event for any problem updating the cache. If the browser doesn't have an Internet connection to the server when it checks the app cache manifest file and can't download the manifest, the application will also get an "error" event. So getting an "error" event can simply mean that the browser is offline, and we don't happen to have an Internet connection at the moment.
And the "error" event has no error code or error message associated with it. The only piece of information that the application receives is that there was a problem updating the cache. We don't know if it was because our Internet connection happened to flake out for a moment, or if the manifest file is incorrectly formatted, or if we've violated some browser imposed limitation.
Ermmm, so the solution is to be very very very very careful and never violate a browser limitation? Because if you do, it will look the same as if your app is always offline.
* * *
In other news I don't actually have the timing / interaction figured out between code updates, the app cache, and livedata figured out yet. The strategy of delaying Meteor startup until the cache has been updated meant that no changes needed to be made to the livedata client code, but it also means the app won't actually work offline (because when it's offline the cache won't get updated). Which is blindingly obvious once I thought of it, but didn't occur to me when I was focused on the code reload issue.
Maybe the trick is to delay the reloading of the web page in reload.js until the app cache has been updated. Because at that point there's no point in reloading the web page if the browser will just reload the old code from the cache.