Skip to main content
Version: Next

SessionPoolOptions

Index

Properties

optionalcreateSessionFunction

createSessionFunction?: CreateSession

Custom function that should return a Session instance, or a promise resolving to such instance. Any error thrown from this function will terminate the process. Receives { sessionOptions } already merged from the pool-wide defaults and the per-call overrides.

optionalid

id?: string | number

Unique identifier for this session pool instance. Used to generate a unique persistence key when persistStateKey is not provided. If not provided, an auto-incrementing ID is used.

optionalmaxPoolSize

maxPoolSize?: number = 1000

Maximum size of the pool. Indicates how many sessions are rotated.

optionalpersistenceOptions

persistenceOptions?: PersistenceOptions

Control how and when to persist the state of the session pool.

optionalpersistStateKey

persistStateKey?: string = CRAWLEE_SESSION_POOL_STATE_{id}

Session pool persists its state under this key in Key value store.

optionalpersistStateKeyValueStoreId

persistStateKeyValueStoreId?: string

Name or Id of KeyValueStore where is the SessionPool state stored.

optionalsessionOptions

sessionOptions?: SessionOptions

The configuration options for Session instances.

optionalsessionReuseStrategy

sessionReuseStrategy?: random | round-robin | use-until-failure = random | round-robin | use-until-failure

Strategy for picking sessions from the pool.

  • 'random' (default): fills the pool up to maxPoolSize, then picks a random usable session
  • 'round-robin': fills the pool up to maxPoolSize, then reuses sessions cycling through them in order
  • 'use-until-failure': always reuses the same session until it is retired, then moves to the next one