Skip to content

fix(netbox): retry network failures and surface fetch error cause - #470

Open
horner wants to merge 2 commits into
mainfrom
fix/netbox-fetch-retry
Open

fix(netbox): retry network failures and surface fetch error cause#470
horner wants to merge 2 commits into
mainfrom
fix/netbox-fetch-retry

Conversation

@horner

@horner horner commented Sep 6, 2026

Copy link
Copy Markdown
Member

Fixes #469

  • nbFetch now goes through fetchWithRetry: 3 attempts with linear backoff on network-level errors (DNS, connect, TLS). HTTP error responses still throw immediately.
  • Thrown error includes err.cause.code (e.g. EAI_AGAIN, ECONNREFUSED) and the request URL instead of the opaque fetch failed.

Verified NetBox itself was healthy and the failing request never reached nginx — see the issue for the investigation.

undici reports DNS/connect/TLS failures as a bare 'fetch failed', hiding
the real reason in err.cause. Log the cause and URL, and retry
network-level failures (3 attempts, backoff). HTTP error responses are
not retried.

Fixes #469
Copilot AI lite review requested due to automatic review settings September 6, 2026 03:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves the NetBox integration used during container lifecycle operations by adding retry/backoff behavior for network-level fetch() failures and by surfacing the underlying undici error cause in the thrown message, addressing the opaque “fetch failed” reported in #469.

Changes:

  • Added fetchWithRetry() with configurable attempts and linear backoff for network failures.
  • Routed nbFetch() through fetchWithRetry() so NetBox API calls benefit from retry behavior.
  • Improved failure messaging to include request method/URL and underlying err.cause details.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread create-a-container/utils/netbox.js
Rethrow non-network exceptions (bad URL, abort) immediately instead of
retrying them and masking the original error.
@horner

horner commented Sep 6, 2026

Copy link
Copy Markdown
Member Author

Addressed in 6c7326e: fetchWithRetry now only retries undici's TypeError('fetch failed') with a cause; everything else is rethrown immediately.

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.

NetBox registration fails with opaque "fetch failed" and no retry

2 participants