@scrapa/sdk 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,9 +49,9 @@ const DEFAULT_MAX_WAIT_SECS = 10;
49
49
  /**
50
50
  * Should this failure be retried?
51
51
  *
52
- * if (attempt < 3 && shouldRetry(error, { repeatable: method === "GET" || !!key }))
52
+ * if (attempt < 3 && isRetryable(error, { repeatable: method === "GET" || !!key }))
53
53
  */
54
- export function shouldRetry(error: unknown, options: RetryOptions): boolean {
54
+ export function isRetryable(error: unknown, options: RetryOptions): boolean {
55
55
  const { repeatable, durableCodes = [], maxWaitSecs = DEFAULT_MAX_WAIT_SECS } = options;
56
56
  const status = statusOf(error);
57
57
  // No answer at all: nothing about it is a refusal, but a write may have landed before the
@@ -145,7 +145,7 @@ export function parseRetryAfter(value: string | null | undefined): number | unde
145
145
  * frees when another job ends. Present-and-`null` is the whole test; an absent key said nothing.
146
146
  *
147
147
  * Not exported. It is not "is this refusal durable?": it knows nothing of `durableCodes` or of a
148
- * wait too long to hold, so a screen branching on it would disagree with `shouldRetry`.
148
+ * wait too long to hold, so a screen branching on it would disagree with `isRetryable`.
149
149
  */
150
150
  function waitingNeverHelps(error: unknown): boolean {
151
151
  const details = field(error, "details");
@@ -24,7 +24,7 @@
24
24
  * - **The header is read first, in both its forms.** Two copies read the body's wait before the
25
25
  * `Retry-After` header, and read the header only as seconds, so an HTTP date was no wait at all.
26
26
  */
27
- import { parseRetryAfter, retryDelayMs, shouldRetry } from "./retry.ts";
27
+ import { parseRetryAfter, retryDelayMs, isRetryable } from "./retry.ts";
28
28
 
29
29
  /** What a generated method tells the transport about its operation. */
30
30
  export interface RequestSpec {
@@ -193,7 +193,7 @@ export async function send<T = unknown, M = unknown>(
193
193
  };
194
194
  const again =
195
195
  attempt < maxRetries &&
196
- shouldRetry(answer, { repeatable, durableCodes: transport.durableCodes });
196
+ isRetryable(answer, { repeatable, durableCodes: transport.durableCodes });
197
197
  if (!again) throw transport.error(failure);
198
198
  await sleep(retryDelayMs(attempt, answer), signal);
199
199
  }