Skip to content

Commit 430e5fd

Browse files
committed
Merge branch 'kmyr-fwd-errors-stop-listening'
2 parents 25cd3ce + e0860a2 commit 430e5fd

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

test.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,12 @@ tests.FWD_ERRORS_1 = function () {
453453
var toThrow = new Error("Forced exception");
454454
var recordedError = null;
455455

456-
var originalHandlers = client3.listeners("error");
456+
var originalHandlers = {
457+
"error": client3.listeners("error"),
458+
"message": client3.listeners("message")
459+
};
457460
client3.removeAllListeners("error");
461+
client3.removeAllListeners("message");
458462
client3.once("error", function (err) {
459463
recordedError = err;
460464
});
@@ -470,8 +474,15 @@ tests.FWD_ERRORS_1 = function () {
470474

471475
client.publish(name, "Some message");
472476
setTimeout(function () {
473-
client3.listeners("error").push(originalHandlers);
474477
assert.equal(recordedError, toThrow, "Should have caught our forced exception");
478+
client3.unsubscribe(name);
479+
client3.removeAllListeners("message");
480+
originalHandlers.error.forEach(function (fn) {
481+
client3.on("error", fn);
482+
});
483+
originalHandlers.message.forEach(function (fn) {
484+
client3.on("message", fn);
485+
});
475486
next(name);
476487
}, 150);
477488
};

0 commit comments

Comments
 (0)