Skip to content

Commit

Permalink
fix: catch errors on socket.write
Browse files Browse the repository at this point in the history
  • Loading branch information
entropitor committed May 10, 2021
1 parent 2ea4ca4 commit fd3d300
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/http-proxy/passes/ws-incoming.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,12 @@ module.exports = {
proxyReq.on('response', function (res) {
// if upgrade event isn't going to happen, close the socket
if (!res.upgrade && !socket.destroyed) {
socket.write(createHttpHeader('HTTP/' + res.httpVersion + ' ' + res.statusCode + ' ' + res.statusMessage, res.headers));
res.pipe(socket);
try {
socket.write(createHttpHeader('HTTP/' + res.httpVersion + ' ' + res.statusCode + ' ' + res.statusMessage, res.headers));
res.pipe(socket);
} catch (error) {
console.error(error)
}
}
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@datacamp/http-proxy",
"version": "1.18.2",
"version": "1.18.3",
"repository": {
"type": "git",
"url": "https://github.com/datacamp-engineering/node-http-proxy.git"
Expand Down

0 comments on commit fd3d300

Please sign in to comment.