fix(watercrawl): bound result download timeout (#37495)

This commit is contained in:
落尘 2026-06-16 16:16:16 +08:00 committed by GitHub
parent f9ed81c3f4
commit fe64c5d4a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -217,7 +217,7 @@ class WaterCrawlAPIClient(BaseAPIClient):
return event_data["data"]
def download_result(self, result_object: dict[str, Any]):
response = httpx.get(result_object["result"], timeout=None)
response = httpx.get(result_object["result"], timeout=30)
try:
response.raise_for_status()
result_object["result"] = response.json()

View File

@ -242,11 +242,18 @@ class TestWaterCrawlAPIClient:
client = WaterCrawlAPIClient(api_key="k")
response = _response(200, {"markdown": "body"})
monkeypatch.setattr(client_module.httpx, "get", lambda *args, **kwargs: response)
captured = {}
def fake_get(*args, **kwargs):
captured.update(kwargs)
return response
monkeypatch.setattr(client_module.httpx, "get", fake_get)
result = client.download_result({"result": "https://example.com/result.json"})
assert result["result"] == {"markdown": "body"}
assert captured["timeout"] is not None
response.close.assert_called_once()