mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
meteor logs -f: Properly close when we get an error from the logsForApp subscription
This commit is contained in:
@@ -534,18 +534,30 @@ _.extend(Meteor._LivedataConnection.prototype, {
|
||||
return handle;
|
||||
},
|
||||
|
||||
_subscribeAndWait: function (/* arguments */) {
|
||||
// options:
|
||||
// - onLateError {Function(error)} called if an error was received after the ready event.
|
||||
// (errors received before ready cause an error to be thrown)
|
||||
_subscribeAndWait: function (name, args, options) {
|
||||
var self = this;
|
||||
var f = new Future();
|
||||
var args = _.toArray(arguments);
|
||||
var ready = false;
|
||||
args = args || [];
|
||||
args.push({
|
||||
onReady: function () { f.return(); },
|
||||
onError: function (e) { f.throw(e); }
|
||||
onReady: function () {
|
||||
ready = true;
|
||||
f.return();
|
||||
},
|
||||
onError: function (e) {
|
||||
if (!ready)
|
||||
f.throw(e);
|
||||
else
|
||||
options && options.onLateError && options.onLateError(e);
|
||||
}
|
||||
});
|
||||
|
||||
self.subscribe.apply(self, args);
|
||||
self.subscribe.apply(self, [name].concat(args));
|
||||
return f.wait();
|
||||
},
|
||||
},
|
||||
|
||||
methods: function (methods) {
|
||||
var self = this;
|
||||
|
||||
@@ -58,10 +58,14 @@ var prettyCall = function (galaxy, name, args, messages) {
|
||||
|
||||
|
||||
var prettySub = function (galaxy, name, args, messages) {
|
||||
try {
|
||||
var ret = galaxy._subscribeAndWait.apply(galaxy, [name].concat(args));
|
||||
} catch (e) {
|
||||
var onError = function (e) {
|
||||
exitWithError(e, messages);
|
||||
};
|
||||
|
||||
try {
|
||||
var ret = galaxy._subscribeAndWait(name, args, {onLateError: onError});
|
||||
} catch (e) {
|
||||
onError(e);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
@@ -207,8 +211,6 @@ exports.logs = function (options) {
|
||||
if (!ok)
|
||||
throw new Error("Couldn't connect to logs mongodb.");
|
||||
|
||||
// XXX make this talk to a separate logReader service instead of
|
||||
// ultraworld direcly
|
||||
prettySub(logReader, "logsForApp", [options.app], {
|
||||
"no-such-app": "No such app: " + options.app
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user