From 06b23cca9466e9645c7db50fbd27055ef90ff6c4 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 29 Oct 2022 04:07:19 -0400 Subject: [PATCH] Fix hang on 500 from site during Find Available PDF Find Available PDF has its own domain-based retry logic that predated automatic 5xx retries in Zotero.HTTP, so disable the latter and fix some bugs in the former. Fixes #2700 --- chrome/content/zotero/xpcom/attachments.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index cb03660bc0..6805293367 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -2079,7 +2079,9 @@ Zotero.Attachments = new function(){ nextURL, { responseType: 'blob', - followRedirects: false + followRedirects: false, + // Use our own error handling + errorDelayMax: 0 } ); } @@ -2090,11 +2092,13 @@ Zotero.Attachments = new function(){ noDelay = false; continue; } - throw e; } break; } afterRequest(nextURL); + if (!req) { + break; + } if ([301, 302, 303, 307].includes(req.status)) { let location = req.getResponseHeader('Location'); if (!location) { @@ -2152,7 +2156,7 @@ Zotero.Attachments = new function(){ } // If DOI resolves directly to a PDF, save it to disk - if (contentType.startsWith('application/pdf')) { + if (contentType && contentType.startsWith('application/pdf')) { Zotero.debug("URL resolves directly to PDF"); await Zotero.File.putContentsAsync(path, blob); await _enforcePDF(path); @@ -2168,7 +2172,7 @@ Zotero.Attachments = new function(){ continue; } if (!url) { - Zotero.debug(`No PDF found on ${responseURL}`); + Zotero.debug(`No PDF found on ${responseURL || pageURL}`); continue; } if (isTriedURL(url)) {