Skip to content

feat: make API node retry parameters configurable via environment variables#13475

Closed
christian-byrne wants to merge 1 commit intomasterfrom
glary/configurable-retry-params
Closed

feat: make API node retry parameters configurable via environment variables#13475
christian-byrne wants to merge 1 commit intomasterfrom
glary/configurable-retry-params

Conversation

@christian-byrne
Copy link
Copy Markdown
Contributor

@christian-byrne christian-byrne commented Apr 19, 2026

PR Created by the Glary-Bot Agent


Summary

  • Adds COMFY_API_MAX_RETRIES, COMFY_API_RETRY_DELAY, and COMFY_API_RETRY_BACKOFF environment variables to override default retry parameters for all API node HTTP requests
  • Users in regions with unstable networks (e.g. behind the GFW in China) can increase the retry budget to tolerate longer network interruptions
  • Defaults remain unchanged (3 retries, 1.0s delay, 2.0x backoff) when env vars are not set
  • Adds 10 unit tests

Context

Users in China experience LocalNetworkError failures because the default retry budget of 3 retries (~7s total) is insufficient for networks with intermittent connectivity. This change lets affected users self-mitigate by increasing retries:

COMFY_API_MAX_RETRIES=10 COMFY_API_RETRY_DELAY=2.0 python main.py

Changes

comfy_api_nodes/util/client.py:

  • Adds _env_int() / _env_float() helpers that read env vars with fallback defaults
  • Adds frozen _RetryDefaults dataclass and RETRY_DEFAULTS singleton
  • Wires RETRY_DEFAULTS into sync_op, sync_op_raw default parameters

comfy_api_nodes/util/download_helpers.py:

  • Wires RETRY_DEFAULTS into download_url_to_bytesio defaults (with max(5, RETRY_DEFAULTS.max_retries) floor)

comfy_api_nodes/util/upload_helpers.py:

  • Wires RETRY_DEFAULTS into upload_file defaults

tests/test_retry_defaults.py — 10 tests:

  • _env_int / _env_float: default, override, invalid value handling
  • _RetryDefaults: hardcoded defaults, env override mechanism, explicit construction, frozen immutability

Verification

Backend Python utility — no browser testing applicable. All 10 unit tests pass. No new LSP diagnostics.

API Node PR Checklist

Scope

  • Is API Node Change

Pricing & Billing

  • Need pricing update
  • No pricing update

If Need pricing update:

  • Metronome rate cards updated
  • Auto‑billing tests updated and passing

QA

  • QA done
  • QA not required

Comms

  • Informed Kosinkadink

…iables

Adds COMFY_API_MAX_RETRIES, COMFY_API_RETRY_DELAY, and
COMFY_API_RETRY_BACKOFF environment variables that override the default
retry parameters for all API node HTTP requests (sync_op, sync_op_raw,
upload_file, download_url_to_bytesio).

Users in regions with unstable networks (e.g. behind the GFW in China)
can increase the retry budget to tolerate longer network interruptions:

  COMFY_API_MAX_RETRIES=10 COMFY_API_RETRY_DELAY=2.0 python main.py

Defaults remain unchanged (3 retries, 1.0s delay, 2.0x backoff) when
the env vars are not set.
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.

2 participants