From 7ecef6b69c923b1cb6841c96d99c232445d833f6 Mon Sep 17 00:00:00 2001 From: Roman Shtylman Date: Wed, 23 Apr 2014 12:10:51 -0400 Subject: [PATCH] make done a no-op if not provided --- server.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index ed96e86..0470394 100644 --- a/server.js +++ b/server.js @@ -60,17 +60,18 @@ function maybe_bounce(req, res, bounce) { // get client port client.next_socket(function(socket, done) { + done = done || function() {}; + // the request already finished or client disconnected if (finished) { return done(); } - // happens when client upstream is disconnected // we gracefully inform the user and kill their conn // without this, the browser will leave some connections open // and try to use them again for new requests // we cannot have this as we need bouncy to assign the requests again - if (!socket) { + else if (!socket) { res.statusCode = 504; res.end(); req.connection.destroy();