mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-09 22:45:49 +00:00
Check if streams are already destroyed before destroying
This commit is contained in:
parent
5fadafaf96
commit
f440cec8ec
2 changed files with 14 additions and 12 deletions
|
@ -61,18 +61,18 @@ function getFile(req, res, next) {
|
|||
}
|
||||
|
||||
pipeline(fileStream, res, err => {
|
||||
if (err) {
|
||||
if (!fileStream.destroyed) {
|
||||
fileStream.destroy()
|
||||
if (err.code === 'ERR_STREAM_PREMATURE_CLOSE') {
|
||||
res.end()
|
||||
} else {
|
||||
next(
|
||||
new Errors.ReadError({
|
||||
message: 'error transferring stream',
|
||||
info: { bucket, key, format, style }
|
||||
}).withCause(err)
|
||||
)
|
||||
}
|
||||
}
|
||||
if (err && err.code === 'ERR_STREAM_PREMATURE_CLOSE') {
|
||||
res.end()
|
||||
} else if (err) {
|
||||
next(
|
||||
new Errors.ReadError({
|
||||
message: 'error transferring stream',
|
||||
info: { bucket, key, format, style }
|
||||
}).withCause(err)
|
||||
)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
@ -114,7 +114,9 @@ function getReadyPipeline(...streams) {
|
|||
}
|
||||
if (err) {
|
||||
for (const stream of streams) {
|
||||
stream.destroy()
|
||||
if (!stream.destroyed) {
|
||||
stream.destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue