mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
In follower, when calling a method with a callback, do not hang waiting for a connection instead defer the method
This commit is contained in:
@@ -92,7 +92,7 @@ Follower = {
|
||||
electorTries[tryingUrl]++;
|
||||
}
|
||||
url = url || findFewestTries();
|
||||
console.log("trying", url, electorTries, tryingUrl, process.env.GALAXY_JOB);
|
||||
//console.log("trying", url, electorTries, tryingUrl, process.env.GALAXY_JOB);
|
||||
|
||||
// Don't keep trying the same url as fast as we can if it's not working.
|
||||
if (electorTries[url] > 2) {
|
||||
@@ -217,8 +217,18 @@ Follower = {
|
||||
// leadership group.
|
||||
conn._applyImpl = conn.apply;
|
||||
conn.apply = function (/* arguments */) {
|
||||
connectedToLeadershipGroup.wait();
|
||||
return conn._applyImpl.apply(conn, arguments);
|
||||
var args = _.toArray(arguments);
|
||||
if (typeof args[args.length-1] === 'function') {
|
||||
// this needs to be independent of this fiber if there is a callback.
|
||||
Meteor.defer(function () {
|
||||
connectedToLeadershipGroup.wait();
|
||||
return conn._applyImpl.apply(conn, args);
|
||||
});
|
||||
return null; // if there is a callback, the return value is not used
|
||||
} else {
|
||||
connectedToLeadershipGroup.wait();
|
||||
return conn._applyImpl.apply(conn, args);
|
||||
}
|
||||
};
|
||||
|
||||
conn.onLost = function (callback) {
|
||||
|
||||
@@ -450,7 +450,6 @@ var runWebAppServer = function () {
|
||||
};
|
||||
} else {
|
||||
proxyConf = configuration.proxy;
|
||||
|
||||
}
|
||||
Log("Attempting to bind to proxy at " + proxyService.providers.proxy);
|
||||
console.log(proxyConf);
|
||||
@@ -477,6 +476,8 @@ var runWebAppServer = function () {
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
var proxy;
|
||||
WebAppInternals.bindToProxy = function (proxyConfig, proxyServiceName) {
|
||||
var securePort = proxyConfig.securePort || 4433;
|
||||
var insecurePort = proxyConfig.insecurePort || 8080;
|
||||
@@ -508,11 +509,18 @@ WebAppInternals.bindToProxy = function (proxyConfig, proxyServiceName) {
|
||||
|
||||
// This is run after packages are loaded (in main) so we can use
|
||||
// Follower.connect.
|
||||
var proxy = Package["follower-livedata"].Follower.connect(
|
||||
proxyConfig.proxyEndpoint, {
|
||||
group: proxyServiceName
|
||||
}
|
||||
);
|
||||
if (proxy) {
|
||||
proxy.reconnect({
|
||||
url: proxyConfig.proxyEndpoint
|
||||
});
|
||||
} else {
|
||||
proxy = Package["follower-livedata"].Follower.connect(
|
||||
proxyConfig.proxyEndpoint, {
|
||||
group: proxyServiceName
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
var route = process.env.ROUTE;
|
||||
var host = route.split(":")[0];
|
||||
var port = +route.split(":")[1];
|
||||
|
||||
Reference in New Issue
Block a user