Repository navigation
Conversation
Signed-off-by: Bugs5382 <[email protected]>
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.
What and why
Connectioncounts reconnect attempts with_retryCount, which starts at 0 and is post-incremented in the socketclosehandler. WithmaxConnectionAttempts: Nthe drops seeretryCount0..N-1 and retry (Nclient.errorevents). The next drop seesretryCount === N, which matched neitherretryCount < NnorretryCount > N, so the handler did nothing: no retry timer, no close, no event, and the connection stayed in CONNECTING forever.retryCount > Nwas unreachable, because the count never advances past N once a close happens.The fix turns the
else if (retryCount > N)into a plainelse, so the attempt after the last allowed retry closes the connection. The retry count and the option's cap (1 to 50) are unchanged.Not touched:
_retryCountis reset to 1 (not 0) on a successful connect, so after a reconnect one fewer retry is allowed. That is a separate quirk and not part of #71.Closes #71
Verification
How this was verified
__tests__/client/hl7.client.test.ts: connect to a port nothing listens on withmaxConnectionAttempts: 2; expects 2client.errorevents and then acloseevent. It failed before the fix (2 errors, no close) and passes after.npm run lint: exit 0.npm run format:check: exit 0.npx vitest run __tests__/client __tests__/server: 586 passed, 2 skipped.npx tsc --noEmit -p packages/node-hl7-clientreports 38 errors on main already (test option typing andcodec.ts); the branch has 39, the extra one being the new test's options object, same kind as the existing ones in that file.check:distnot run (no published-file change beyond one condition).