Skip to content

open-nfse / RetryPolicy

Interface: RetryPolicy

Defined in: src/retry/policy.ts:41

Decide when a transient error becomes eligible for replay. Transience itself is decided by defaultIsTransient (or a custom override) — RetryPolicy owns timing only. A policy is never consulted for permanent errors.

The default implementation reads Retry-After per RFC 7231 and falls back to a constant for 429 / 503 (which semantically mean "back off"). Consumers can implement their own to add jitter, exponential backoff, or environment-specific defaults — see RetryContext for the data available on each call.

Contract: computeNotBefore MUST NOT throw. The lib wraps every configured policy defensively (logging a warning and falling back to undefined) so that a broken custom policy can't mask the original fiscal error, but the wrapper should not be relied upon — assume it isn't there and make the policy itself bulletproof.

Methods

computeNotBefore()

ts
computeNotBefore(
   err: Error, 
   now: Date, 
   context?: RetryContext): Date | undefined;

Defined in: src/retry/policy.ts:47

Returns the earliest moment the entry should be replayed. undefined means "eligible on the next replay tick" — no specific wait beyond whatever cadence the caller already drives.

Parameters

ParameterType
errError
nowDate
context?RetryContext

Returns

Date | undefined

Licença MIT — biblioteca não oficial, sem vínculo com a Receita Federal.