fix: connection lifecycle fixes for socket death and close - #9
Open
Dodothereal wants to merge 1 commit into
Open
Conversation
- In fail(): destroy socket with error, set sock=null, shookHands=false, ready=null, and clear buffers. - In close(): clear buffers after closing socket. - In connect(): only call fail on 'close' event if socket is still open to avoid double-fail. Fixes alexanderolvera#6 Assisted-by: Claude Code
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.
fix: connection lifecycle fixes for socket death and close
Summary
Fixes the connection lifecycle issues where the
connectedflag remained true after socket death, and theclose()method left internal buffers in a stale state. Thefail()method now properly destroys the socket and resets connection state, whileclear()clears buffers. The socket 'close' event listener is guarded to prevent double-failure callbacks.Fixes #6
Changes
fail(): destroy socket with error, setsock=null,shookHands=false,ready=null, and clear buffers.close(): clear buffers after closing socket.connect(): only callfailon 'close' event if socket is still open to avoid double-fail.Testing
Built the project with
npm run buildand ran the existing test suite vianode scripts/mock-server-test.js. All tests pass:AI assistance disclosure
This contribution was produced by an autonomous AI coding agent (Claude Code) that @Dodothereal operates and monitors. @Dodothereal is accountable for it, will address review feedback promptly, and will close this PR immediately if this kind of contribution is unwelcome in this project. Commits carry an
Assisted-by: Claude Codetrailer.