From 5803dfbf2f241a3c2e6c0cd088f941de634166ca Mon Sep 17 00:00:00 2001 From: Nick Martin Date: Thu, 21 Nov 2013 16:31:49 -0800 Subject: [PATCH] Comments and safety belts from glasser's review. --- packages/autoupdate/autoupdate_client.js | 10 +++++----- packages/autoupdate/autoupdate_server.js | 21 ++++++++++++++------- packages/livedata/livedata_connection.js | 6 +++--- packages/livedata/stream_server.js | 8 ++++---- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/packages/autoupdate/autoupdate_client.js b/packages/autoupdate/autoupdate_client.js index 2216e80c3f..6a0d6386cb 100644 --- a/packages/autoupdate/autoupdate_client.js +++ b/packages/autoupdate/autoupdate_client.js @@ -1,16 +1,16 @@ // Subscribe to the `meteor_autoupdate_clientVersions` collection, // which contains the set of acceptable client versions. // -// A "hard code push" occurs when the current client version is not in +// A "hard code push" occurs when the running client version is not in // the set of acceptable client versions (or the server updates the -// collection, and the current client version is no longer in the -// set). +// collection, there is a published client version marked `current` and +// the running client version is no longer in the set). // // When the `reload` package is loaded, a hard code push causes // the browser to reload, so that it will load the latest client // version from the server. // -// A "soft code push" represents the situation when the current client +// A "soft code push" represents the situation when the running client // version is in the set of acceptable versions, but there is a newer // version available on the server. // @@ -24,7 +24,7 @@ // The client version of the client code currently running in the // browser. -var autoUpdateVersion = __meteor_runtime_config__.autoUpdateVersion; +var autoUpdateVersion = __meteor_runtime_config__.autoUpdateVersion || "unknown"; // The collection of acceptable client versions. diff --git a/packages/autoupdate/autoupdate_server.js b/packages/autoupdate/autoupdate_server.js index 1d0031e76d..648ce0d553 100644 --- a/packages/autoupdate/autoupdate_server.js +++ b/packages/autoupdate/autoupdate_server.js @@ -45,10 +45,12 @@ AutoUpdate = {}; AutoUpdate.autoUpdateVersion = null; Meteor.startup(function () { + // Allow people to override AutoUpdate.autoUpdateVersion before + // startup. Tests do this. if (AutoUpdate.autoUpdateVersion === null) AutoUpdate.autoUpdateVersion = process.env.AUTOUPDATE_VERSION || - process.env.SERVER_ID || + process.env.SERVER_ID || // XXX COMPAT 0.6.6 WebApp.clientHash; // Make autoUpdateVersion available on the client. @@ -63,12 +65,17 @@ Meteor.publish( // Using `autoUpdateVersion` here is safe because we can't get a // subscription before webapp starts listening, and it doesn't do // that until the startup hooks have run. - self.added( - "meteor_autoupdate_clientVersions", - AutoUpdate.autoUpdateVersion, - {current: true} - ); - self.ready(); + if (AutoUpdate.autoUpdateVersion) { + self.added( + "meteor_autoupdate_clientVersions", + AutoUpdate.autoUpdateVersion, + {current: true} + ); + self.ready(); + } else { + // huh? shouldn't happen. Just error the sub. + self.error(new Meteor.Error(500, "AutoUpdate.autoUpdateVersion not set")); + } }, {is_auto: true} ); diff --git a/packages/livedata/livedata_connection.js b/packages/livedata/livedata_connection.js index 15b37d1b96..81f05de24c 100644 --- a/packages/livedata/livedata_connection.js +++ b/packages/livedata/livedata_connection.js @@ -181,9 +181,9 @@ var Connection = function (url, options) { } if (msg === null || !msg.msg) { - // DEPRECATED. ignore the old welcome message for back compat. - // Remove this 'if' once the server stops sending welcome messages - // (stream_server.js). + // XXX COMPAT WITH 0.6.6. ignore the old welcome message for back + // compat. Remove this 'if' once the server stops sending welcome + // messages (stream_server.js). if (! (msg && msg.server_id)) Meteor._debug("discarding invalid livedata message", msg); return; diff --git a/packages/livedata/stream_server.js b/packages/livedata/stream_server.js index 160d11e9e8..c675cb9e57 100644 --- a/packages/livedata/stream_server.js +++ b/packages/livedata/stream_server.js @@ -65,10 +65,10 @@ StreamServer = function () { }); self.open_sockets.push(socket); - // DEPRECATED. Send the old style welcome message, which will force - // old clients to reload. Remove this once we're not concerned about - // people upgrading from a pre-0.6.7 release. Also, remove the - // clause in the client that ignores the welcome message + // XXX COMPAT WITH 0.6.6. Send the old style welcome message, which + // will force old clients to reload. Remove this once we're not + // concerned about people upgrading from a pre-0.6.7 release. Also, + // remove the clause in the client that ignores the welcome message // (livedata_connection.js) socket.send(JSON.stringify({server_id: "0"}));