Skip to content

feat: an option to turn off the persistence of the session pool - #28

Merged
metalwarrior665 merged 1 commit into
masterfrom
feat/session-pool-persistence-option
Nov 17, 2026
Merged

metalwarrior665 merged 1 commit into
masterfrom
feat/session-pool-persistence-option

Conversation

@metalwarrior665

Copy link
Copy Markdown
Member

Adds SessionPoolOptions::persistence_enabled (default true), the counterpart of sessionPoolOptions.persistenceOptions.enable in Crawlee for JS. When it is off, the crawler doesn't restore the pool from CRAWLEE_SESSION_POOL_STATE_{id} and never saves it. That means no key-value store read at start, no PersistState listener and no write at the end. The crawler takes the setting from the pool, so it also applies to a pool passed in with .session_pool(...).

Why: some scrapers use sessions only to keep HTTP clients and their connections alive, and saving the pool for them is wasted work. A heap profile showed that serializing a full pool (to_record) costs about 7 MB at a time, every ~60 s. google-maps-rs needs this because the JS Actor it ports sets persistenceOptions: { enable: false }.

The new crawler tests cover both cases. By default, a saved pool is restored and then written over. With the option off, it is neither restored nor written, even after PersistState events.


Generated by Claude Code

`SessionPoolOptions::persistence_enabled` (default `true`) is the
counterpart of `sessionPoolOptions.persistenceOptions.enable` in Crawlee
for JS. Off, the crawler neither restores the pool from its saved state
when the crawl starts nor saves it, on `PersistState` events or at the end:
no key-value store read, no listener, no write.

For crawlers whose sessions only keep HTTP clients and their connections,
saving the pool every minute is wasted work, and serializing it costs
memory: a few MB at a time for a full pool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0148RYR4BTGyCYHENSRZjC3S
@metalwarrior665
metalwarrior665 merged commit 6c92758 into master Nov 17, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants