Skip to content

Commit

Permalink
fix: ignore errors when forcefully closing the socket
Browse files Browse the repository at this point in the history
In order to catch the following errors:

```
events.js:288
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at afterWriteDispatched (internal/stream_base_commons.js:154:25)
    at writeGeneric (internal/stream_base_commons.js:145:3)
    at Socket._writeGeneric (net.js:780:11)
    at Socket._write (net.js:792:8)
    at doWrite (_stream_writable.js:441:12)
    at writeOrBuffer (_stream_writable.js:425:5)
    at Socket.Writable.write (_stream_writable.js:316:11)
    at abortConnection (<myproject>/node_modules/engine.io/lib/server.js:506:12)
    at <myproject>/node_modules/engine.io/lib/server.js:353:7
    at Server.verify (<myproject>/node_modules/engine.io/lib/server.js:158:14)
    at Server.handleUpgrade (<myproject>/node_modules/engine.io/lib/server.js:351:8)
```

Backported from master: dcdbccb
  • Loading branch information
darrachequesne committed Apr 15, 2020
1 parent 21ef608 commit da851ec
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,9 @@ Server.prototype.attach = function (server, options) {
*/

function abortConnection (socket, code) {
socket.on('error', () => {
debug('ignoring error from closed connection');
});
if (socket.writable) {
var message = Server.errorMessages.hasOwnProperty(code) ? Server.errorMessages[code] : String(code || '');
var length = Buffer.byteLength(message);
Expand Down

0 comments on commit da851ec

Please sign in to comment.