Skip to content

feat(crawlers)!: Replace HTTP client persist_cookies_per_session with crawler save_response_cookies - #2366

Open
Mantisus wants to merge 1 commit into
apify:v2from
Mantisus:save-response-cookies
Open

Mantisus wants to merge 1 commit into
apify:v2from
Mantisus:save-response-cookies

Conversation

@Mantisus

@Mantisus Mantisus commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Description

persist_cookies_per_session is removed from the HTTP clients. The HTTP crawlers, PlaywrightCrawler and StagehandCrawler take a new save_response_cookies option instead, as in Crawlee JS. With save_response_cookies=False, the session cookies are still sent, but the cookies set by the responses aren't saved to the session. In PlaywrightCrawler and StagehandCrawler, the option stops saving the cookies of the page to the session after the request handler.

context.send_request always saves the response cookies with BasicCrawler and the HTTP crawlers, whatever the option. In v1, persist_cookies_per_session=False applied to it too. The v2 upgrade guide describes the migration.

Issues

✍️ Drafted by Claude Code

@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Oct 30, 2026
@Mantisus Mantisus self-assigned this Oct 30, 2026
@Mantisus
Mantisus force-pushed the save-response-cookies branch from eb9ff91 to ae6d58b Compare November 3, 2026 15:45
@Mantisus
Mantisus marked this pull request as ready for review November 3, 2026 15:48
@Mantisus
Mantisus requested a review from vdusek November 3, 2026 15:48
Comment on lines +674 to +676

# Kept out of `_PlaywrightCrawlerAdditionalOptions`, since `AdaptivePlaywrightCrawler` passes those to its browser
# sub-crawler only, while its static sub-crawler would keep saving the response cookies.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: AdaptivePlaywrightCrawler has no way to set save_response_cookies. Its **kwargs is _BasicCrawlerOptions, and this field is kept out of playwright_crawler_specific_kwargs, so adaptive users lose the v1 persist_cookies_per_session=False switch with nothing to replace it. Could AdaptivePlaywrightCrawler.__init__, with_beautifulsoup_static_parser and with_parsel_static_parser take save_response_cookies and pass it to both sub-crawlers? The upgrade guide could then mention it.

✍️ Drafted by Claude Code

Comment on lines 50 to 53
"""Helper fixture to reduce code duplication.
If clients are not initialized, create their default instances.
Return client in active context, leave the context after the test."""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: with the "not initialized" line removed, the docstring has a leftover second paragraph. One line is enough:

Suggested change
"""Helper fixture to reduce code duplication.
If clients are not initialized, create their default instances.
Return client in active context, leave the context after the test."""
"""Enter the client passed by indirect parametrization and leave its context after the test."""

✍️ Drafted by Claude Code

@vdusek vdusek changed the title feat(crawlers)!: Replace persist_cookies_per_session with a save_response_cookies crawler option feat(crawlers)!: Replace HTTP client persist_cookies_per_session with crawler save_response_cookies Nov 5, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants