Function createSuspendableDeadline

  • A deadline with a suspendable idle leg and an unsuspendable ceiling.

    Pure and injectable (setTimer/clearTimer) so the suspension rules are unit-testable against a fake clock rather than by waiting minutes for real ones.

    The idle leg RESTARTS in full when a prompt clears rather than resuming where it left off. That is deliberate: after the user dismisses a prompt the host begins fresh work, and the seconds that elapsed before the prompt say nothing about how long that work should take. The ceiling is what stops a repeatedly-prompting call from running forever.

    Parameters

    • opts: {
          bounds: CallBounds;
          clearTimer?: (handle: unknown) => void;
          onExpire: (bound: DeadlineBound, boundMs: number) => void;
          setTimer?: (fn: () => void, ms: number) => unknown;
      }
      • bounds: CallBounds
      • OptionalclearTimer?: (handle: unknown) => void
      • onExpire: (bound: DeadlineBound, boundMs: number) => void

        Called once, with the bound that elapsed and its length in ms.

      • OptionalsetTimer?: (fn: () => void, ms: number) => unknown

    Returns SuspendableDeadline