mirror of
https://github.com/usestrix/strix.git
synced 2026-10-13 03:57:59 +00:00
fix(proxy): log Caido timeouts as warnings
This commit is contained in:
parent
442b3c3df5
commit
c5854e7be2
2 changed files with 17 additions and 1 deletions
|
|
@ -124,7 +124,11 @@ def _no_client() -> str:
|
|||
|
||||
|
||||
def _err(name: str, exc: Exception) -> str:
|
||||
logger.exception("%s failed", name)
|
||||
# The Caido SDK wraps its GraphQL timeout in an error with an empty message.
|
||||
if isinstance(exc.__cause__, TimeoutError):
|
||||
logger.warning("%s timed out", name)
|
||||
else:
|
||||
logger.exception("%s failed", name)
|
||||
return json.dumps(
|
||||
{"success": False, "error": f"{name} failed: {exc}"},
|
||||
ensure_ascii=False,
|
||||
|
|
|
|||
|
|
@ -252,3 +252,15 @@ async def test_existing_request_ids_queries_current_project(
|
|||
|
||||
assert existing == {"1042"}
|
||||
assert looked_up == ["1042", "1088"]
|
||||
|
||||
|
||||
def test_err_logs_caido_timeout_as_warning(caplog: pytest.LogCaptureFixture) -> None:
|
||||
exc = RuntimeError()
|
||||
exc.__cause__ = TimeoutError()
|
||||
|
||||
with caplog.at_level("WARNING", logger="strix.tools.proxy.tools"):
|
||||
tools._err("list_requests", exc)
|
||||
|
||||
[record] = caplog.records
|
||||
assert record.levelname == "WARNING"
|
||||
assert record.exc_info is None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue