Reset state on credential loading failure#1107
Conversation
When ConnectAsync throws during credential loading (e.g. missing creds file), ConnectionState stays at Connecting and the waiter TCS is never completed. A second ConnectAsync call then hangs forever waiting on that TCS. Wrap credential loading in InitialConnectAsync with a try-catch that resets ConnectionState to Closed and faults the waiter, matching the existing pattern for socket and setup failures. Also broaden the catch in LoadCredsFile from NatsException to Exception so IO errors like FileNotFoundException are wrapped properly.
|
Claude finished @mtmk's task in 2m 1s —— View job PR Review: Reset state on credential loading failure
SummaryThe fix is correct and well-targeted. The new try-catch in
The No double-wrapping: when One minor consistency note
// LoadCredsContent – unchanged, still NatsException only
catch (NatsException e)
// LoadCredsFile – correctly broadened in this PR
catch (Exception e)
No issues found with:
Verdict: LGTM. The fix is minimal, correct, and consistent with the existing error-handling pattern. |
|
hey @Prochy are you able to confirm this fix is working for you? |
Just tested, it works. |
When ConnectAsync throws during credential loading (e.g. missing creds file), ConnectionState stays at Connecting and the waiter TCS is never completed. A second ConnectAsync call then hangs forever waiting on that TCS.
Wrap credential loading in InitialConnectAsync with a try-catch that resets ConnectionState to Closed and faults the waiter, matching the existing pattern for socket and setup failures. Also broaden the catch in LoadCredsFile from NatsException to Exception so IO errors like FileNotFoundException are wrapped properly.
fixes #1104