MCPcopy
hub / github.com/triggerdotdev/trigger.dev / calculateNextRetryDelay

Function calculateNextRetryDelay

packages/core/src/v3/utils/retries.ts:29–44  ·  view source on GitHub ↗
(options: RetryOptions, attempt: number)

Source from the content-addressed store, hash-verified

27 * @returns
28 */
29export function calculateNextRetryDelay(options: RetryOptions, attempt: number) {
30 const opts = { ...defaultRetryOptions, ...options };
31
32 if (attempt >= opts.maxAttempts) {
33 return;
34 }
35
36 const { factor, minTimeoutInMs, maxTimeoutInMs, randomize } = opts;
37
38 const random = randomize ? Math.random() + 1 : 1;
39
40 const timeout = Math.min(maxTimeoutInMs, random * minTimeoutInMs * Math.pow(factor, attempt - 1));
41
42 // Round to the nearest integer
43 return Math.round(timeout);
44}
45
46export function calculateResetAt(
47 resets: string | undefined | null,

Callers 7

_doZodFetchFunction · 0.90
shouldRetryForOptionsFunction · 0.90
#handleErrorMethod · 0.90
onThrowFunction · 0.90
retryFetchFunction · 0.90
#doWorkInternalMethod · 0.90

Calls 2

randomMethod · 0.80
minMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…