Skip to content
Permalink
Browse files

fix(server): add missing file from previous commit

  • Loading branch information...
mycoboco committed Jul 9, 2019
1 parent 611400a commit 90f01c2a22c4c1bd3aa82b7dd2a397e02b8d8257
Showing with 23 additions and 0 deletions.
  1. +23 −0 server/lib/safePipe.js
@@ -0,0 +1,23 @@
/*
* wrapper for stream pipes to avoid broken pipe;
* to be replaced by @hodgepodge-node/util/safePipe()
*/


module.exports = function (rs, ws, _handler) {
var handler = function (err) {
rs.unpipe(ws)
ws.end()
_handler && _handler(err)
}

ws.on('unpipe', function () {
rs.once('readable', function () { rs.destroy() })
})
ws.on('error', handler)
.on('close', function () { rs.unpipe(ws) })
rs.on('error', handler)
rs.pipe(ws)
}

// end of safePipe.js

0 comments on commit 90f01c2

Please sign in to comment.
You can’t perform that action at this time.