From 1e94069acbb7153ade178db781bc4a2e01b16cf2 Mon Sep 17 00:00:00 2001 From: Eric Mc Sween Date: Wed, 8 Feb 2023 08:27:09 -0500 Subject: [PATCH] Merge pull request #11718 from overleaf/em-cancelled-history-requests Ignore ERR_STREAM_PREMATURE_CLOSE when proxying requests GitOrigin-RevId: aedfa90cc54da041d1c26da3081b6cd72eb5aeb6 --- .../app/src/Features/History/HistoryController.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/services/web/app/src/Features/History/HistoryController.js b/services/web/app/src/Features/History/HistoryController.js index b6181c5db5..6fec20ac63 100644 --- a/services/web/app/src/Features/History/HistoryController.js +++ b/services/web/app/src/Features/History/HistoryController.js @@ -54,7 +54,9 @@ module.exports = HistoryController = { }, }) pipeline(getReq, res, function (err) { - if (err) { + // If the downstream request is cancelled, we get an + // ERR_STREAM_PREMATURE_CLOSE. + if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') { logger.warn({ url, err }, 'history API error') next(err) } @@ -353,7 +355,9 @@ module.exports = HistoryController = { const getReq = request({ ...options, method: 'get' }) pipeline(getReq, res, function (err) { - if (err) { + // If the downstream request is cancelled, we get an + // ERR_STREAM_PREMATURE_CLOSE. + if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') { logger.error({ url, err }, 'history API error') next(err) } @@ -433,7 +437,9 @@ module.exports = HistoryController = { res.status(response.statusCode) prepareZipAttachment(res, `${name}.zip`) pipeline(response, res, err => { - if (err) { + // If the downstream request is cancelled, we get an + // ERR_STREAM_PREMATURE_CLOSE. + if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') { logger.warn( { err, v1ProjectId, version, retryAttempt }, 'history s3 proxying error'