Skip to content

Commit

Permalink
#1904. Don't crash if a write to a client fails, which can happen som…
Browse files Browse the repository at this point in the history
…etimes when a client has left but some data is still buffered.
  • Loading branch information
orospakr committed Apr 1, 2011
1 parent 3b0e6b8 commit 15ff38c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/mmsh-client-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ module.exports.MMSHClientSession = function(stream, verifyIsIDUnique) {
response.write(header_bin);
this.data_handler = function(data_packet, repacked_data) {
log.debug(c, this.client_id + ": sending data packet to attached client...");
response.write(repacked_data);
try {
response.write(repacked_data);
} catch(e) {
// client disconnected, otherwise unavailable. happens sometimes when clients disconnected and there's some buffering going on.
}
}.bind(this);
stream.on("Data", this.data_handler);
req.socket.once("close", function(if_error) {
Expand Down

0 comments on commit 15ff38c

Please sign in to comment.