fix: Preserve inner state when auto-sense client gets unknown version#63
Closed
fix: Preserve inner state when auto-sense client gets unknown version#63
Conversation
Move the DetectedVersion::Unknown check before self.inner.take() so that returning an error does not leave inner as None. Previously, poll_output() and handle_timeout() would panic after handle_packet() encountered an unrecognized server response in auto-sense client mode. Fixes #62
When ClientPending transitions to Client12/Client13, the engine timeouts remain Unarmed because new_from_hybrid does not call handle_timeout. This causes poll_timeout to hit unreachable!(). Also wrap all fallible calls after inner.take() in if-let-Err patterns to restore self.inner on error, preventing it from being left as None.
algesten
commented
Feb 28, 2026
| self.inner = Some(Inner::Server13(server)); | ||
| return Err(e); | ||
| } | ||
| self.inner = Some(Inner::Server13(server)); |
Owner
Author
There was a problem hiding this comment.
Looks like the self.inner assignment is undconditional and should happen before if-let?
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.
Summary
DetectedVersion::Unknowncheck beforeself.inner.take()so that returning an error does not leaveinnerasNonepoll_output()andhandle_timeout()would panic withunwrap() on Noneafterhandle_packet()encountered an unrecognized server response in auto-sense client modepoll_outputandhandle_timeoutwork after the errorFixes #62
Test plan
test_auto_client_unknown_version_no_panic— feeds garbage to an auto-sense client, assertsUnexpectedMessageerror, then callshandle_timeoutandpoll_outputwithout panic