Procházet zdrojové kódy

Merge pull request #11718 from overleaf/em-cancelled-history-requests

Ignore ERR_STREAM_PREMATURE_CLOSE when proxying requests

GitOrigin-RevId: aedfa90cc54da041d1c26da3081b6cd72eb5aeb6
Eric Mc Sween před 3 roky
rodič
revize
1e94069acb

+ 9 - 3
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'