Skip to content

Commit

Permalink
chore: reduce maxRetryAfterTime 10 by default
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Oct 30, 2022
1 parent c4a4c37 commit 96cd2bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,18 @@ Customize `User-Agent` http header.

The max of waiting seconds for retry. It is related to `retry` option.

:memo: It does affect to `Retry-After` header. If you want to max waiting seconds for `Retry-After` header, please use `maxRetryAfterTime` option.
:memo: It does affect to [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header. If you want to max waiting seconds for `Retry-After` header, please use `maxRetryAfterTime` option.

Default: `10`

### maxRetryAfterTime

The max of allow waiting time second for `maxRetryAfterTime` header value.
The max of allow waiting time second for [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header value.

Default: `90`
Some website like GitHub returns `Retry-After` header value with `429 too many requests`.
This `maxRetryAfterTime` option is for that `Retry-After`.

Default: `10`

## Tests

Expand Down
4 changes: 2 additions & 2 deletions src/no-dead-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const DEFAULT_OPTIONS: Options = {
keepAlive: false, // {boolean} if it is true, use keepAlive for checking request [Experimental]
userAgent: "textlint-rule-no-dead-link/1.0", // {String} a UserAgent,
maxRetryTime: 10, // (number) The max of waiting seconds for retry. It is related to `retry` option. It does affect to `Retry-After` header.
maxRetryAfterTime: 90 // (number) The max of waiting seconds for `Retry-After` header.
maxRetryAfterTime: 10 // (number) The max of waiting seconds for `Retry-After` header.
};

// Adopted from http://stackoverflow.com/a/3809435/951517
Expand Down Expand Up @@ -231,7 +231,7 @@ const createCheckAliveURL = (ruleOptions: Options) => {
if (currentRetryCount < maxRetryCount) {
const retryAfter = res.headers.get("Retry-After");
// If the response has `Retry-After` header, prefer it
// e.g. Retry-After: 60 and `maxRetryAfterTime: 90`, wait 60 seconds
// e.g. `Retry-After: 60` and `maxRetryAfterTime: 90`, wait 60 seconds
if (retryAfter) {
const retryAfterMs = Number(retryAfter) * 1000;
const maxRetryAfterTimeMs = ruleOptions.maxRetryAfterTime * 1000;
Expand Down

0 comments on commit 96cd2bb

Please sign in to comment.