Skip to content

Fix: request /crawl with stream: true issue #1066 #1074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

zinodynn
Copy link

@zinodynn zinodynn commented May 5, 2025

Summary

Fixes #1066
This PR fixes the error that happens when you send a request to /crawl with stream: true in the crawler_config.
What’s the fix?

If a request has stream: true, it now automatically redirects (307) to the /crawl/stream endpoint.

No more async_generator errors

List of files changed and why

  1. deploy/docker/server.py
  • Added a check for stream: true in the /crawl request handler.
  • If detected, redirects to /crawl/stream instead of trying to process it in the wrong place.
  1. deploy/docker/static/playground/index.html
  • update stream configuration based on endpoint selection (/crawl :stream is False, /crawl/stream : stream is True )
    image
  1. tests/docker/test_server_requests.py
  • add test for crawl endpoint with stream redirects

How Has This Been Tested?

Tested with curl(like the issue example)
eg.

curl --location 'http://localhost:11235/crawl' \
--header 'Content-Type: application/json' \
--data '{
    "urls": [
        "https://example.com/page1",  
        "https://example.com/page2",
    ],
    "crawler_config": {
        "type": "CrawlerRunConfig",
        "params": {
            "scraping_strategy": {
                "type": "WebScrapingStrategy",
            },
            "stream": true
        }
    }
}'

Got a 307 redirect to /crawl/stream, and the streaming worked!

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added/updated unit tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@zinodynn zinodynn changed the title Zinodynn/issue1066 Fix: /crawl with stream: true issue #1066 May 5, 2025
@zinodynn zinodynn changed the title Fix: /crawl with stream: true issue #1066 Fix: request /crawl with stream: true issue #1066 May 5, 2025
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.

[Bug]: TypeError: 'async_generator' object is not iterable when processing crawl requests with multiple URLs
1 participant