Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / retry

Function: retry()

retry<T>(factory, maxRetries?, delay?): Stream<T>

Defined in: projects/libraries/streamix/src/lib/streams/retry.ts:19

Creates a stream that subscribes to a source factory and retries the entire sequence on error.

Values are yielded as each attempt produces them. If an attempt fails after emitting some values, those values stay visible downstream and the operator restarts the factory for the next attempt.

Abortion: the operator honors the abort signal during stream iteration and between-retry delays, clearing allocations safely without event listener leaks.

Type Parameters

T

T = any

The type of values emitted by the source stream.

Parameters

factory

() => Stream<T> | Promise<T>

A factory function executed on each initialization attempt.

maxRetries?

MaybePromise<number> = 3

The maximum number of retry operations allowed. A value of 0 runs a single attempt.

delay?

MaybePromise<number> = 1000

The delay window in milliseconds to pause between attempts.

Returns

Stream<T>

A stream that retries the sequence factory after errors.

Released under the GNU AGPL v3 or later.