Conversation
When EPP responses arrived in multiple chunks, the read counter would reset to its previous value instead of accumulating.
This caused the code to think it hadn't read as many bytes as it actually had, leading to "Unexpected EOF while reading" errors.
```
2026-02-05T12:02:05.416810Z DEBUG: instant_epp::connection: Expected response length: 2539
2026-02-05T12:02:05.417597Z DEBUG: instant_epp::connection: Read 1172 bytes, 1428 out of 2539 done
2026-02-05T12:02:05.417637Z DEBUG: instant_epp::connection: Read 1111 bytes, 1367 out of 2539 done
```
The connection state machine's pattern destructuring creates copies of state fields instead of mutable references into the struct. When these were modified (e.g., incrementing read counter), the modifications were lost because the original state was returned.
Example:
```
RequestState::Reading { mut read, buf, expected } => { // copies read
...
read += filled.len(); // Modifies LOCAL copy
...
Transition::Next(state) // Returns ORIGINAL state with OLD read value
}
```
Fix: Construct new state objects with updated values:
```
RequestState::Reading { read, buf, expected } => {
let new_read = *read + filled.len(); // Calculate new value
// Return NEW state with updated counter
Transition::Next(RequestState::Reading {
read: new_read,
buf: mem::take(buf),
expected: *expected,
})
}
djc
approved these changes
Feb 5, 2026
Owner
djc
left a comment
There was a problem hiding this comment.
Nice, thanks for fixing this upstream and adding test coverage!
Would be curious to hear what/where you're using it.
| use std::time::Duration; | ||
|
|
||
| use async_trait::async_trait; | ||
| use rstest::rstest; |
Owner
There was a problem hiding this comment.
I'm not a fan of adding this new dependency with unfamiliar attribute macro stuff. Can you just write a few #[test] functions with maybe a simple helper function?
| } | ||
|
|
||
| start += wrote; | ||
| let new_start = *start + wrote; |
Owner
There was a problem hiding this comment.
Nit: I'd prefer to just shadow the old binding, keeping it as start (here and below).
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.
When EPP responses arrived in multiple chunks, the read counter would reset to its previous value instead of accumulating.
This caused the code to think it hadn't read as many bytes as it actually had, leading to "Unexpected EOF while reading" errors.
The connection state machine's pattern destructuring creates copies of state fields instead of mutable references into the struct. When these were modified (e.g., incrementing read counter), the modifications were lost because the original state was returned.
Example:
Fix: Construct new state objects with updated values: