MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / calculateRetryAt

Function calculateRetryAt

packages/core/src/retry.ts:11–34  ·  view source on GitHub ↗
(retryOptions: RetryOptions, attempts: number)

Source from the content-addressed store, hash-verified

9} satisfies RetryOptions;
10
11export function calculateRetryAt(retryOptions: RetryOptions, attempts: number): Date | undefined {
12 const options = {
13 ...DEFAULT_RETRY_OPTIONS,
14 ...retryOptions,
15 };
16
17 const retryCount = attempts + 1;
18
19 if (retryCount >= options.limit) {
20 return;
21 }
22
23 const random = options.randomize ? Math.random() + 1 : 1;
24
25 let timeoutInMs = Math.round(
26 random *
27 Math.max(options.minTimeoutInMs, 1) *
28 Math.pow(options.factor, Math.max(attempts - 1, 0))
29 );
30
31 timeoutInMs = Math.min(timeoutInMs, options.maxTimeoutInMs);
32
33 return new Date(Date.now() + timeoutInMs);
34}
35
36export function calculateResetAt(
37 resets: string | undefined | null,

Callers 3

executeTaskMethod · 0.90

Calls 3

randomMethod · 0.80
maxMethod · 0.80
minMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…