Skip to content

Reference

CouponMinter.waitUntilCanMint

Async loop that sleeps until canMintCouponsNow reports canMint, with max wait, poll floor, abort signal, and onWaitStart callback.

waitUntilCanMint repeatedly calls canMintCouponsNow after sleeping for max(result.waitMs, minPollIntervalMs), capped by remaining maxWaitMs.

Example

await ocp.CouponMinter.waitUntilCanMint(COUPON_MINTER_PAYLOAD, {
  maxWaitMs: 300_000,
  minPollIntervalMs: 100,
  signal: abortController.signal,
  onWaitStart: (ms) => console.log(`Backing off ${ms}ms`),
});

Options (WaitUntilCanMintOptions)

  • maxWaitMs (optional) — default 300000 (5 minutes).
  • minPollIntervalMs (optional) — default 100.
  • signal (optional)AbortSignal; abort → WaitAbortedError.
  • onWaitStart (optional) — called with the sleep duration about to run.

Errors

  • WaitAbortedError — immediate abort or abort during sleep.
  • WaitTimeoutError — elapsed time exceeds maxWaitMs while still rate limited.
  • Propagates OcpValidationError from canMintCouponsNow if payload is invalid.

See also

Source