Skip to main content
Version: Next

ISessionPool

Minimal contract that any object passed to a crawler as its sessionPool option must satisfy.

Crawlers only depend on a single method of the built-in SessionPool: getSession() / getSession(id) to hand out an ISession for a request. Lifecycle (reset, teardown) is the responsibility of whoever owns the pool — since a user-supplied pool is never owned by the crawler, the crawler never tears it down.

Implement this interface to plug a custom session-management strategy into any Crawlee crawler — for example a remote, multi-process pool, a database-backed pool, or a thin wrapper around the built-in SessionPool with different rotation rules.

Implemented by

Index

Methods

Methods

getSession

  • getSession(sessionId): Promise<undefined | ISession>
  • Returns a usable ISession. Without an id, the pool decides which session to return (creating a new one when appropriate). With an id, the pool returns the matching session if it is still usable.

    In case the SessionPool cannot provide a usable session given the configuration, this method may return undefined.


    Parameters

    • optionalsessionId: string

    Returns Promise<undefined | ISession>

Page Options