Repository navigation
feat(crawlers): implement Request.skip_navigation to skip navigation and run the handler directly - #2338
Open
enriquealonso01 wants to merge 1 commit into
Open
feat(crawlers): implement Request.skip_navigation to skip navigation and run the handler directly#2338enriquealonso01 wants to merge 1 commit into
Request.skip_navigation to skip navigation and run the handler directly#2338enriquealonso01 wants to merge 1 commit into
Conversation
…and run the handler directly Implements the previously unused `skip_navigation` flag (apify#2311): when set, BasicCrawler bypasses the context pipeline (whose middlewares perform the navigation) and invokes the request handler directly. Accessing the navigation-only `request.loaded_url` member raises the new public `NavigationSkippedError`, mirroring the JS SDK behavior (apify/crawlee #3107, #3381). - add public `NavigationSkippedError` to crawlee.errors - add `Request.skip_navigation` property backed by CrawleeRequestData (persisted/serialized via the existing `skipNavigation` alias) - BasicCrawler: route skip-navigation requests around the context pipeline - regression tests for end-to-end behavior and serialization roundtrip
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2311
CrawleeRequestData.skip_navigationwas declared, persisted and serialized asskipNavigation, but nothing insrc/crawleeread it — setting it had no effect.This implements the flag with the same semantics as JS SDK v4 (apify/crawlee#3107, apify/crawlee#3381), per janbuchar's direction in the issue:
request.skip_navigationisTrue,BasicCrawlerbypasses the context pipeline (whose middlewares perform the navigation) and invokes the request handler directly.request.loaded_urlmember raises the new publicNavigationSkippedErrorinstead of returningNone.BasicCrawler-level helpers (push_data,add_requests,send_request) instead.Not breaking: the flag's storage format is unchanged, and accessing navigation-only members of a plain (navigated) context behaves exactly as before.
Testing
tests/unit/crawlers: 590 passed, 1 skipped; the only 2 failures (parsel xhtml-as-xml, playwright firefox headless) fail identically on clean master (stash-verified, pre-existing)tests/unit/test_request.py: 4/4 passruff check+ruff formatclean on all touched files