Skip to content

Commit

Permalink
Merge pull request #709 from minrk/close-on-error
Browse files Browse the repository at this point in the history
close socket if upstream request fails
  • Loading branch information
jcrugzz committed Oct 1, 2014
2 parents 43c6f0c + c627663 commit fcdbf46
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/http-proxy/passes/ws-incoming.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ var passes = exports;
} else {
server.emit('error', err, req, socket);
}
socket.end();
}
}

Expand Down
9 changes: 8 additions & 1 deletion test/lib-http-proxy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,24 @@ describe('lib/http-proxy.js', function() {
client.on('open', function () {
client.send('hello there');
});

var count = 0;
function maybe_done () {
count += 1;
if (count === 2) done();
}

client.on('error', function (err) {
expect(err).to.be.an(Error);
expect(err.code).to.be('ECONNRESET');
maybe_done();
});

proxy.on('error', function (err) {
expect(err).to.be.an(Error);
expect(err.code).to.be('ECONNREFUSED');
proxyServer.close();
done();
maybe_done();
});
});

Expand Down

0 comments on commit fcdbf46

Please sign in to comment.