mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Move serverId to __meteor_runtime_config__. This prevents a race condition where the server restarts between when the client loads app.html and when it makes a DDP connection. Fixes #653. Thanks @awwx!
This commit is contained in:
@@ -7,7 +7,6 @@ Meteor._Stream = function (url) {
|
||||
self.rawUrl = url;
|
||||
self.socket = null;
|
||||
self.event_callbacks = {}; // name -> [callback]
|
||||
self.server_id = null;
|
||||
self.sent_update_available = false;
|
||||
self.force_fail = false; // for debugging.
|
||||
|
||||
@@ -202,10 +201,8 @@ _.extend(Meteor._Stream.prototype, {
|
||||
}
|
||||
|
||||
if (welcome_data && welcome_data.server_id) {
|
||||
if (!self.server_id)
|
||||
self.server_id = welcome_data.server_id;
|
||||
|
||||
if (self.server_id && self.server_id !== welcome_data.server_id &&
|
||||
if (__meteor_runtime_config__.serverId &&
|
||||
__meteor_runtime_config__.serverId !== welcome_data.server_id &&
|
||||
!self.sent_update_available) {
|
||||
self.update_available = true;
|
||||
_.each(self.event_callbacks.update_available,
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
// unique id for this instantiation of the server. If this changes
|
||||
// between client reconnects, the client will reload. You can set the
|
||||
// environment variable "SERVER_ID" to control this. For example, if
|
||||
// you want to only force a reload on major changes, you can use a
|
||||
// custom serverId which you only change when something worth pushing
|
||||
// to clients immediately happens.
|
||||
__meteor_runtime_config__.serverId =
|
||||
process.env.SERVER_ID ? process.env.SERVER_ID : Meteor.uuid();
|
||||
|
||||
Meteor._StreamServer = function () {
|
||||
var self = this;
|
||||
self.registration_callbacks = [];
|
||||
self.open_sockets = [];
|
||||
|
||||
// unique id for this instantiation of the server. If this changes
|
||||
// between client reconnects, the client will reload. You can set the
|
||||
// environment variable "SERVER_ID" to control this. For example, if
|
||||
// you want to only force a reload on major changes, you can use a
|
||||
// custom server_id which you only change when something worth pushing
|
||||
// to clients immediately happens.
|
||||
if (process.env.SERVER_ID)
|
||||
self.server_id = process.env.SERVER_ID;
|
||||
else
|
||||
self.server_id = Meteor.uuid();
|
||||
|
||||
// set up sockjs
|
||||
var sockjs = __meteor_bootstrap__.require('sockjs');
|
||||
self.server = sockjs.createServer({
|
||||
@@ -44,9 +42,9 @@ Meteor._StreamServer = function () {
|
||||
self.open_sockets.push(socket);
|
||||
|
||||
|
||||
// Send a welcome message with the server_id. Client uses this to
|
||||
// Send a welcome message with the serverId. Client uses this to
|
||||
// reload if needed.
|
||||
socket.send(JSON.stringify({server_id: self.server_id}));
|
||||
socket.send(JSON.stringify({server_id: __meteor_runtime_config__.serverId}));
|
||||
|
||||
// call all our callbacks when we get a new socket. they will do the
|
||||
// work of setting up handlers and such for specific messages.
|
||||
|
||||
Reference in New Issue
Block a user