From c899ea4ef7bd3d70332f33cbf2ba662739b504b1 Mon Sep 17 00:00:00 2001 From: Jedrzej Kosinski Date: Mon, 11 May 2026 12:37:10 -0700 Subject: [PATCH] feat(api-nodes): plumb auth_headers, base_url, error_parser, rate_limit_label through sync_op/poll_op - Add auth_headers/base_url passthrough so RNP and other clients can override the default Comfy auth + base URL on a per-request basis without a node_cls. - Add _parse_retry_after helper that honors RFC 7231 Retry-After (seconds or HTTP-date), feeding the existing 429 / SERVER_BUSY / MAINTENANCE backoff. - Add rate_limit_label callback so callers can render a friendlier per-second status (e.g. 'Server busy, retrying in 30s...') during a rate-limit sleep; the in-flight monitor task is paused so the two writers don't race. - Add error_parser callback so structured protocol errors (e.g. RNP RnpProtocolError) bubble unchanged instead of being flattened by _friendly_http_message; typed errors are also re-raised from poll_op_raw. - Add allow_304 path returning None on conditional GETs. - Allow node_cls=None for non-workflow callers; _display_text becomes a no-op. - _diagnose_connectivity / ApiServerError respect the resolved base_url. Amp-Thread-ID: https://ampcode.com/threads/T-019e1889-d8bd-732f-8170-b85fd94da503 Co-authored-by: Amp --- comfy_api_nodes/util/client.py | 226 ++++++++++++++++++++++++++++++--- 1 file changed, 210 insertions(+), 16 deletions(-) diff --git a/comfy_api_nodes/util/client.py b/comfy_api_nodes/util/client.py index 052301c33..b32075d43 100644 --- a/comfy_api_nodes/util/client.py +++ b/comfy_api_nodes/util/client.py @@ -51,7 +51,7 @@ class ApiEndpoint: @dataclass class _RequestConfig: - node_cls: type[IO.ComfyNode] + node_cls: type[IO.ComfyNode] | None endpoint: ApiEndpoint timeout: float content_type: str @@ -70,6 +70,17 @@ class _RequestConfig: price_extractor: Callable[[dict[str, Any]], float | None] | None = None is_rate_limited: Callable[[int, Any], bool] | None = None response_header_validator: Callable[[dict[str, str]], None] | None = None + base_url: str | None = None + auth_headers: dict[str, str] | None = None + allow_304: bool = False + error_parser: Callable[[int, Any], Exception | None] | None = None + # Optional callback to render a per-second progress label while + # waiting out a rate-limit / SERVER_BUSY / MAINTENANCE retry. Called + # with ``(status, body, retry_after_s)`` and should return the label + # string used by ``_display_time_progress`` (which renders it as + # ``Status: