Skip to main content
Version: Next

RecoverableStateOptions <TStateModel, TPersistedState>

Options for configuring the RecoverableState

Hierarchy

Index

Properties

optionalconfiguration

configuration?: Configuration

Configuration instance to use when opening the KeyValueStore

defaultState

defaultState: TStateModel | () => TStateModel

The state used when no persisted state is found, and the state RecoverableState.reset restores.

A plain value is deep-copied with structuredClone each time it is used, so pass a factory for a state that structuredClone cannot rebuild - one holding class instances, say, or one derived from a schema.

optionaldeserialize

deserialize?: StateConversion<TPersistedState, TStateModel>

Optional conversion of a persisted value back to the state model, and the place to validate a record before trusting it. If not provided, the persisted value is used as is.

optionalinheritedkeyValueStore

keyValueStore?: KeyValueStore | PromiseLike<KeyValueStore>

The KeyValueStore to persist into, defaulting to the default store. Accepts a pending KeyValueStore.open so that callers do not have to be async to point at a specific store.

optionallogger

logger?: CrawleeLogger

A logger instance for logging operations related to state persistence

optionalinheritedpersistenceEnabled

persistenceEnabled?: boolean

Flag to enable or disable state persistence

optionalinheritedpersistenceTimeoutMillis

persistenceTimeoutMillis?: number = 60_000

Time limit for a single load or save of the state, in milliseconds.

inheritedpersistStateKey

persistStateKey: string

The key under which the state is stored in the KeyValueStore

optionalserialize

serialize?: StateConversion<TStateModel, TPersistedState>

Optional conversion of the state to a plain JSON-serializable value before it is persisted. If not provided, the state is persisted as is.