You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[VDR] ERR-8508619d · Connection-level retries are unbounded and silent for the first ~50 seconds #2216
The except ServerDisconnectedError and except ClientOSError branches increment a local retries counter that is never compared against MAX_NUM_TRIES (only the generic except Exception branch at line 259 enforces the cap). A permanently unreachable server therefore loops forever rather than raising. Because DISCONNECTED_CLIENT_OS_PRINT_INTERVAL is 100 and each iteration sleeps 0.5s, the first diagnostic is withheld for ~50s, so the user sees a completely silent hang with no way to tell a slow model from a dead one.
Suggested fix: Apply the MAX_NUM_TRIES cap to all three branches and re-raise the original error once exhausted, with a message naming the URL and the likely cause (server not started / wrong port). Print on the first failure, not every 100th. Separately, honor the documented exponential backoff by replacing the flat asyncio.sleep(0.5) with a growing delay plus jitter.
Details
Severity
🔴 critical
Path
nemo_gym/server_utils.py:224
Finding ID
ERR-8508619d
Found by
error-quality-auditor
Workstream
[VDR][v0.5.0] Runtime reliability
Status
⟳ also reported 2026-06-30 (as ERR-967ecc03) — still unfixed
Evidence
$ python -c 'await request("GET","http://127.0.0.1:1/health")' with 8s wait_for -> STILL RETRYING after 8.0s -> UNBOUNDED (server_utils.py:194 MAX_NUM_TRIES=3; :198 PRINT_INTERVAL=100)
A question came up on which branch actually catches an unreachable server — the intuition being that a connection failure would fall through to the generic except Exception at server_utils.py#L248 and therefore be printed and bounded.
It does not. A connection error never reaches L248.
ClientConnectorError (connection refused) and ClientConnectorDNSError (DNS failure) are both subclasses of ClientOSError:
Python evaluates except clauses top-down, so except ClientOSError at L236 catches them before L248 is ever considered. Confirmed on the aiohttp version we pin (3.14.3).
Which branch catches what
Failure mode
Exception
Caught at
Bounded?
First output
Connection refused (internal or external)
ClientConnectorError
L236 ClientOSError
❌ never raises
~50s
DNS failure (external host)
ClientConnectorDNSError
L236 ClientOSError
❌ never raises
~50s
Peer drops mid-request
ServerDisconnectedError
L224
❌ never raises
~50s
Timeout
ServerTimeoutError / asyncio.TimeoutError
L248 Exception
✅ 3 tries
immediate
HTTP / other error
ClientResponseError, plain OSError
L248 Exception
✅ 3 tries
immediate
Only the last two rows respect MAX_NUM_TRIES.
_internal does not change this
_internal only gates the print at L253 — and that is inside the bounded branch (which raises at L259). Neither connection-error branch inspects _internal at all, so an external server hangs exactly the same as a Gym-spawned internal one.
Runtime repro
Against a closed port, through the real request():
MAX_NUM_TRIES = 3 | PRINT_INTERVAL = 100
_internal=False -> STILL RETRYING (never raised) after 60s
[request_retry url=http://127.0.0.1:1/x error=ClientOSError retry=100 elapsed_s=49.7] Hit 100 global `ClientOSError` ...
_internal=True -> STILL RETRYING (never raised) after 60s
[request_retry url=http://127.0.0.1:1/x error=ClientOSError retry=80 elapsed_s=39.7] Hit 200 global `ClientOSError` ...
Second issue this surfaced: the print counter is global, not per-request
_NUM_CLIENT_OS_ERROR is a module-level global. Note the second probe above printed at retry=80, not retry=100, because the counter had already reached 200 during the first probe. Consequences:
The print cadence depends on unrelated concurrent traffic rather than on this request's own retry count.
The retry=N field in the message does not correspond to the retry count of the URL being named.
Under high concurrency the message fires often but names an arbitrary one of the failing URLs; with a single failing request it takes a full ~50s.
Implication for the fix
Capping needs to happen in the two connection branches specifically — moving the cap into the generic handler will not help, since connection errors never get there. Suggested:
Apply MAX_NUM_TRIES to the ServerDisconnectedError and ClientOSError branches, re-raising the original exception once exhausted with the URL and likely cause (server not started / wrong port).
Print on the first failure, not every 100th.
Make the retry counter per-request rather than a module global (or keep the global purely for aggregate telemetry and drive the message off the local retries).
Replace the flat asyncio.sleep(0.5) with growing delay + jitter, which is what the docs already claim happens.
Verified against ba167e07; nemo_gym/server_utils.py is byte-identical to e446e4f4, the ref the original review ran on, so nothing has drifted.
Activity
anwithk commentedon Jul 30, 2026
Verified error profile
A question came up on which branch actually catches an unreachable server — the intuition being that a connection failure would fall through to the generic
except Exceptionatserver_utils.py#L248and therefore be printed and bounded.It does not. A connection error never reaches L248.
ClientConnectorError(connection refused) andClientConnectorDNSError(DNS failure) are both subclasses ofClientOSError:Python evaluates
exceptclauses top-down, soexcept ClientOSErrorat L236 catches them before L248 is ever considered. Confirmed on the aiohttp version we pin (3.14.3).Which branch catches what
ClientConnectorErrorClientOSErrorClientConnectorDNSErrorClientOSErrorServerDisconnectedErrorServerTimeoutError/asyncio.TimeoutErrorExceptionClientResponseError, plainOSErrorExceptionOnly the last two rows respect
MAX_NUM_TRIES._internaldoes not change this_internalonly gates the print at L253 — and that is inside the bounded branch (which raises at L259). Neither connection-error branch inspects_internalat all, so an external server hangs exactly the same as a Gym-spawned internal one.Runtime repro
Against a closed port, through the real
request():Second issue this surfaced: the print counter is global, not per-request
_NUM_CLIENT_OS_ERRORis a module-level global. Note the second probe above printed atretry=80, notretry=100, because the counter had already reached 200 during the first probe. Consequences:retry=Nfield in the message does not correspond to the retry count of the URL being named.Implication for the fix
Capping needs to happen in the two connection branches specifically — moving the cap into the generic handler will not help, since connection errors never get there. Suggested:
MAX_NUM_TRIESto theServerDisconnectedErrorandClientOSErrorbranches, re-raising the original exception once exhausted with the URL and likely cause (server not started / wrong port).retries).asyncio.sleep(0.5)with growing delay + jitter, which is what the docs already claim happens.Verified against
ba167e07;nemo_gym/server_utils.pyis byte-identical toe446e4f4, the ref the original review ran on, so nothing has drifted.fix: classify connection failures and report them on the first occurr…
feat(cli): wait for model endpoints to accept connections before a run
fix: route a failed /run into the failures sidecar instead of ending …
fix: classify connection failures and report them on the first occurr…
feat(cli): wait for model endpoints to accept connections before a run
fix: route a failed /run into the failures sidecar instead of ending …
feat(cli): wait for model endpoints to accept connections before a run
10 remaining items
feat(cli): check model endpoints before starting a run
feat(cli): check model endpoints before starting a run
feat(cli): check model endpoints before starting a run
feat(cli): check model endpoints before starting a run (#2362)
feat(cli): check model endpoints before starting a run (NVIDIA-NeMo#2362
fix: classify connection failures and report them on the first occurr…
fix: bound how long a socket connect can hang
fix: classify connection failures and report them on the first occurr…
fix: bound how long a socket connect can hang
fix(model): bound connection retries whenever route-around is on (NVI…
fix(core): bound internal retries by the retry cap (NVIDIA-NeMo#3914)