Skip to content

Commit b30efac

Browse files
committed
Protect connection retries from application exceptions
1 parent aa50c78 commit b30efac

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

index.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,27 @@ RedisClient.prototype.flush_and_error = function (message) {
118118
while (this.offline_queue.length > 0) {
119119
command_obj = this.offline_queue.shift();
120120
if (typeof command_obj.callback === "function") {
121-
command_obj.callback(message);
121+
try {
122+
command_obj.callback(message);
123+
} catch (callback_err) {
124+
process.nextTick(function () {
125+
throw callback_err;
126+
});
127+
}
122128
}
123129
}
124130
this.offline_queue = new Queue();
125131

126132
while (this.command_queue.length > 0) {
127133
command_obj = this.command_queue.shift();
128134
if (typeof command_obj.callback === "function") {
129-
command_obj.callback(message);
135+
try {
136+
command_obj.callback(message);
137+
} catch (callback_err) {
138+
process.nextTick(function () {
139+
throw callback_err;
140+
});
141+
}
130142
}
131143
}
132144
this.command_queue = new Queue();

0 commit comments

Comments
 (0)