overleaf/patches/send+0.17.2.patch
Jakob Ackermann 67a21bdc69 Merge pull request #13056 from overleaf/jpa-pipeline-express
[misc] use stream.pipeline in express libraries

GitOrigin-RevId: a6a50864552237b0c4d153d9f272cdc8d0f297ea
2023-05-25 08:03:47 +00:00

61 lines
1.5 KiB
Diff

diff --git a/node_modules/send/index.js b/node_modules/send/index.js
index 06d7507..8854216 100644
--- a/node_modules/send/index.js
+++ b/node_modules/send/index.js
@@ -795,31 +795,31 @@ SendStream.prototype.stream = function stream (path, options) {
// pipe
var stream = fs.createReadStream(path, options)
this.emit('stream', stream)
- stream.pipe(res)
-
- // response finished, done with the fd
- onFinished(res, function onfinished () {
- finished = true
- destroy(stream)
- })
-
- // error handling code-smell
- stream.on('error', function onerror (err) {
- // request already finished
- if (finished) return
-
- // clean up stream
- finished = true
- destroy(stream)
-
- // error
- self.onStatError(err)
- })
-
- // end
- stream.on('end', function onend () {
- self.emit('end')
- })
+ Stream.pipeline(stream, res, err => { if (err) { self.onStatError(err) } else { self.emit('end') } })
+
+ // // response finished, done with the fd
+ // onFinished(res, function onfinished () {
+ // finished = true
+ // destroy(stream)
+ // })
+ //
+ // // error handling code-smell
+ // stream.on('error', function onerror (err) {
+ // // request already finished
+ // if (finished) return
+ //
+ // // clean up stream
+ // finished = true
+ // destroy(stream)
+ //
+ // // error
+ // self.onStatError(err)
+ // })
+ //
+ // // end
+ // stream.on('end', function onend () {
+ // self.emit('end')
+ // })
}
/**