fix(cli): retry registry requests and fall back to IPv4 - #47
Open
dennytosp wants to merge 1 commit into
Open
Conversation
`getRegistry` and `getComponentCode` called `fetch` once with no timeout and no retry. On dual-stack networks that advertise an unroutable AAAA record for the registry host, the connect attempt hangs until undici gives up and the command fails with a raw `UND_ERR_CONNECT_TIMEOUT`. Route both requests through a helper that retries up to three times with a backoff, switches the DNS resolver to `ipv4first` after a connect-level failure so a broken IPv6 route can recover, and applies an explicit timeout that `REACTICX_FETCH_TIMEOUT` can raise. The final error now explains what to try and keeps the original error as its `cause`, and failed responses report their HTTP status. Fixes rit3zh#39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #39
Problem
npx reacticx list/reacticx add <component>fail on some networks with a raw undici error:Cause
getRegistryandgetComponentCodeeach calledfetchexactly once, with no timeout, no retry, and no error handling beyondresponse.ok. On a dual-stack network that advertises an AAAA record for the registry host but cannot actually route IPv6, the first connect hangs until undici gives up — and there is nothing to recover it. The reporter also had no way to raise the timeout, and the thrown error gave no hint about what to try.Fix
Both requests now go through a
fetchWithRetryhelper that:fetchonly rejects on transport-level failures (an HTTP error status resolves normally), so anything thrown is worth another attempt;ipv4firstafter a connect-level failure (UND_ERR_CONNECT_TIMEOUT,EHOSTUNREACH,ENETUNREACH,ETIMEDOUT), so a broken IPv6 route recovers on the next attempt. This is only applied as a fallback, so IPv6-only networks are unaffected;REACTICX_FETCH_TIMEOUT=<milliseconds>;causeso the underlying code is still visible.Failed responses now also report their HTTP status (
Failed to fetch registry (404 Not Found)) instead of a bare message.Verification
Against the live registry —
list,list -c organisms, andaddall behave as before.With a stubbed
fetch, exercising each path:cause=UND_ERR_CONNECT_TIMEOUTipv4firstECONNRESET)verbatimREACTICX_FETCH_TIMEOUT=1234tsc --noEmitandtsupboth pass. No new dependencies —node:dnsonly.