From b4e3693226cd0efa18fc23fcbacc64ee90ba4020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Fri, 14 Apr 2023 10:58:52 +0200 Subject: [PATCH] Fix HEAD not being retried for HTTP 500 category responses. See #579 --- lib/upload.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/upload.js b/lib/upload.js index 83dfa35b..82a16fdf 100644 --- a/lib/upload.js +++ b/lib/upload.js @@ -616,6 +616,14 @@ class BaseUpload { this._emitHttpError(req, res, 'tus: upload is currently locked; retry later') return } + if (inStatusCategory(status, 500)) { + // Run retry logic if the server has an error, e.g. 502 Bad Gateway when + // proxied server is temporarily down. See issue #579. + // Since we want to retry, do not clear `this.url` and do not + // create a new upload. + this._emitHttpError(req, res, 'tus: resuming upload resulted in HTTP 500 category error') + return + } if (inStatusCategory(status, 400)) { // Remove stored fingerprint and corresponding endpoint,