Skip to content

Commit

Permalink
Return response when response is ok
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoalh committed Aug 9, 2023
1 parent 2157a78 commit c6adc3b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ body:
description: "What versions are affected? Versions must be listed as supported in the Security Policy (file: `SECURITY.md`)."
multiple: true
options:
- "v0.1.2"
- "v0.1.1"
- "v0.1.0"
validations:
Expand Down
3 changes: 2 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"recommended"
]
}
}
},
"lock": false
}
9 changes: 6 additions & 3 deletions exfetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ export class ExFetch {
let response: Response;
do {
response = await fetch(input, { ...init, signal });
if (
response.ok ||
attempt >= this.#retry.attempts
) {
break;
}
let retryable: boolean = statusCodeRetryable.has(response.status);
if (typeof this.#retry.condition === "function") {
if (!this.#retry.condition(response.status, retryable)) {
Expand All @@ -282,9 +288,6 @@ export class ExFetch {
break;
}
}
if (attempt >= this.#retry.attempts) {
break;
}
let delayTime: number;
let headerRetryAfterValue: string | null = response.headers.get("Retry-After");
if (typeof headerRetryAfterValue === "string") {
Expand Down

0 comments on commit c6adc3b

Please sign in to comment.