Skip to content

Commit

Permalink
Merge pull request #1 from datacamp-engineering/catch-errors-socket-w…
Browse files Browse the repository at this point in the history
…rite

Catch errors on socket write
  • Loading branch information
entropitor committed May 10, 2021
2 parents 2ea4ca4 + fd3d300 commit 080e129
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 080e129

Please sign in to comment.