fix: retry immediately on non-positive numeric Retry-After header
The numeric Retry-After branch multiplied the header value by 1000 without guarding non-positive results, so `Retry-After: 0` produced a falsy delay that fell through to exponential backoff instead of retrying immediately. The RFC-1123 date branch already clamps non-positive values to 1ms; mirror that guard in the numeric branch so a non-positive Retry-After retries at once.
This commit is contained in:
1 parent
7eb9032cf2
commit
3ce94ca09d
2 files changed
+25
No files matched your search
@@ -304,6 +304,27 @@ test('retries on 503 without Retry-After header', withServer, async (t, server,
|
||||
t.is(retryCount, 1);
|
||||
});
|
||||
|
||||
test('retries immediately on non-positive numeric Retry-After', withServer, async (t, server, got) => {
|
||||
server.get('/', (_request, response) => {
|
||||
response.writeHead(503, {
|
||||
'Retry-After': 0,
|
||||
});
|
||||
response.end();
|
||||
});
|
||||
|
||||
const start = Date.now();
|
||||
const {statusCode, retryCount} = await got({
|
||||
throwHttpErrors: false,
|
||||
retry: {
|
||||
limit: 2,
|
||||
},
|
||||
});
|
||||
|
||||
t.is(statusCode, 503);
|
||||
t.is(retryCount, 2);
|
||||
t.true(Date.now() - start < 1000);
|
||||
});
|
||||
|
||||
test('doesn\'t retry on streams', withServer, async (t, server, got) => {
|
||||
server.get('/', () => {});
|
||||
|
||||
|
||||
Reference in new issue
Block a user