diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index f08fac9b68..7fc028f7f6 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -880,6 +880,7 @@ Zotero.Utilities.Internal = { var delay; var totalTime = 0; var last = false; + intervals = intervals.slice(); while (true) { let interval = intervals.shift(); if (interval) { diff --git a/test/tests/httpTest.js b/test/tests/httpTest.js index 5f9c2b1160..761459d744 100644 --- a/test/tests/httpTest.js +++ b/test/tests/httpTest.js @@ -288,6 +288,29 @@ describe("Zotero.HTTP", function () { assert.approximately(delayStub.args[0][0], 5 * 1000, 5); assert.approximately(delayStub.args[1][0], 10 * 1000, 5); }); + + it("should start with first interval on new request() call", async function () { + var called = 0; + server.respond(function (req) { + if (req.method == "GET" && req.url.startsWith(baseURL + "error")) { + if (called < 1) { + req.respond(500, {}, ""); + } + else { + req.respond(200, {}, ""); + } + } + called++; + }); + spy = sinon.spy(Zotero.HTTP, "_requestInternal"); + var errorDelayIntervals = [20]; + await Zotero.HTTP.request("GET", baseURL + "error1", { errorDelayIntervals }) + called = 0; + await Zotero.HTTP.request("GET", baseURL + "error2", { errorDelayIntervals }), + assert.equal(4, spy.callCount); + assert.equal(delayStub.args[0][0], 20); + assert.equal(delayStub.args[1][0], 20); + }); }); });