A retry plan can be modeled as deterministic data before it drives real scheduling.

retry plan Model retry timing as plain data first so tracing can inspect the resulting plan.

Retry Plan Case

maxRetries
retry.ts
Replay: real traced execution (multi-file project)
type RetryPlan = {
    attempts: number[];
    finalDelay: number;
};

function buildRetryPlan(maxRetries: number): RetryPlan {
    const attempts: number[] = [];

    for (let retry = 1; retry <= maxRetries; retry += 1) {
        attempts.push(retry * 100);
    }

    const finalDelay: number = attempts.length === 0 ? 0 : attempts[attempts.length - 1];
    return { attempts, finalDelay };
}

const maxRetries: number = 3;
const plan: RetryPlan = buildRetryPlan(maxRetries);

console.log(`attempts=${plan.attempts.join(",")};final=${plan.finalDelay}`);
type RetryPlan = {
    attempts: number[];
    finalDelay: number;
};

function buildRetryPlan(maxRetries: number): RetryPlan {
    const attempts: number[] = [];

    for (let retry = 1; retry <= maxRetries; retry += 1) {
        attempts.push(retry * 100);
    }

    const finalDelay: number = attempts.length === 0 ? 0 : attempts[attempts.length - 1];
    return { attempts, finalDelay };
}

const maxRetries: number = 1;
const plan: RetryPlan = buildRetryPlan(maxRetries);

console.log(`attempts=${plan.attempts.join(",")};final=${plan.finalDelay}`);
  1. maxRetries ← 3

    14    return { attempts, finalDelay };15}1617const maxRetries→ 3: number = 3;  //@maxRetries=118const plan: RetryPlan = buildRetryPlan(maxRetries3);
  2. attempts ← (empty)

    3    finalDelay: number;4};56function buildRetryPlan(maxRetries3: number): RetryPlan {7    const attempts→ (empty): number[] = [];
  3. attempts ← 100, retry ← 1

    pass 1 of 3
    6function buildRetryPlan(maxRetries: number): RetryPlan {7    const attempts: number[] = [];89    for (let retry1 = 1; retry <= maxRetries3; retry += 1) {10        attempts.push(retry→ 1 * 100);11    }
    values this step(empty) 100attempts
    All 3 passes — pass 1 is the card above
    passattemptsretry
    1(empty) 1001
    2100 100,2002
    3100,200 100,200,3003
  4. finalDelay ← 300, attempts.length ← 3

    10        attempts.push(retry * 100);11    }1213    const finalDelay→ 300: number = attempts.length→ 3 === 0 ? 0 : attempts[attempts.length - 1]300;14    return { attempts, finalDelay };15}
  5. plan ← [object Object]

    17const maxRetries: number = 3;  //@maxRetries=118const plan→ [object Object]: RetryPlan = buildRetryPlan(maxRetries3);1920console.log(`attempts=${plan.attempts100,200,300.join(",")};final=${plan.finalDelay300}`);
    outputattempts=100,200,300;final=300
  1. maxRetries ← 1

    14    return { attempts, finalDelay };15}1617const maxRetries→ 1: number = 1;18const plan: RetryPlan = buildRetryPlan(maxRetries1);
  2. attempts ← (empty)

    3    finalDelay: number;4};56function buildRetryPlan(maxRetries1: number): RetryPlan {7    const attempts→ (empty): number[] = [];
  3. attempts ← 100, retry ← 1

    6function buildRetryPlan(maxRetries: number): RetryPlan {7    const attempts: number[] = [];89    for (let retry1 = 1; retry <= maxRetries1; retry += 1) {10        attempts.push(retry→ 1 * 100);11    }
    values this step(empty) 100attempts
  4. finalDelay ← 100, attempts.length ← 1

    10        attempts.push(retry * 100);11    }1213    const finalDelay→ 100: number = attempts.length→ 1 === 0 ? 0 : attempts[attempts.length - 1]100;14    return { attempts, finalDelay };15}
  5. plan ← [object Object]

    17const maxRetries: number = 1;18const plan→ [object Object]: RetryPlan = buildRetryPlan(maxRetries1);1920console.log(`attempts=${plan.attempts100.join(",")};final=${plan.finalDelay100}`);
    outputattempts=100;final=100