fix(watercrawl): bound client request timeouts (#37515)

This commit is contained in:
落尘 2026-06-21 08:47:25 +08:00 committed by GitHub
parent dcff1870d5
commit adfd820220
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -12,6 +12,8 @@ from core.rag.extractor.watercrawl.exceptions import (
WaterCrawlPermissionError,
)
WATERCRAWL_REQUEST_TIMEOUT: httpx.Timeout = httpx.Timeout(30.0, connect=5.0)
class SpiderOptions(TypedDict):
max_depth: int
@ -48,7 +50,7 @@ class BaseAPIClient:
"User-Agent": "WaterCrawl-Plugin",
"Accept-Language": "en-US",
}
return httpx.Client(headers=headers, timeout=None)
return httpx.Client(headers=headers, timeout=WATERCRAWL_REQUEST_TIMEOUT)
def _request(
self,

View File

@ -73,6 +73,9 @@ class TestBaseAPIClient:
assert client.session == "session"
assert captured["headers"]["X-API-Key"] == "k"
assert captured["headers"]["User-Agent"] == "WaterCrawl-Plugin"
assert captured["timeout"] is not None
assert captured["timeout"].connect is not None
assert captured["timeout"].read is not None
def test_request_stream_and_non_stream_paths(self, monkeypatch: pytest.MonkeyPatch):
class FakeSession: