diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index dc09a08566..4f7a38238f 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -853,6 +853,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 dd03b59d18..04fa1bf802 100644 --- a/test/tests/httpTest.js +++ b/test/tests/httpTest.js @@ -260,6 +260,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); + }); }); });