mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-03 20:22:59 +00:00
Merge pull request #109 from overleaf/spd-end-stream-on-premature-close
Call end() when handing ERR_STREAM_PREMATURE_CLOSE
This commit is contained in:
commit
51a6dda660
2 changed files with 13 additions and 1 deletions
|
@ -61,7 +61,12 @@ function getFile(req, res, next) {
|
|||
}
|
||||
|
||||
pipeline(fileStream, res, err => {
|
||||
if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
|
||||
if (!fileStream.destroyed) {
|
||||
fileStream.destroy()
|
||||
}
|
||||
if (err && err.code === 'ERR_STREAM_PREMATURE_CLOSE') {
|
||||
res.end()
|
||||
} else if (err) {
|
||||
next(
|
||||
new Errors.ReadError({
|
||||
message: 'error transferring stream',
|
||||
|
|
|
@ -112,6 +112,13 @@ function getReadyPipeline(...streams) {
|
|||
}
|
||||
resolve(lastStream)
|
||||
}
|
||||
if (err) {
|
||||
for (const stream of streams) {
|
||||
if (!stream.destroyed) {
|
||||
stream.destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pipeline(...streams).catch(handler)
|
||||
|
|
Loading…
Reference in a new issue