fix: multichunk reads#84
Conversation
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.
|
Sorry for the delay, those fixes have been pushed up.
I am currently trying to use the library to talk to nominet |
djc
left a comment
There was a problem hiding this comment.
Some minor nits, please also squash all of your commits.
| use instant_epp::client::{Connector, EppClient}; | ||
| use instant_epp::Error; | ||
|
|
||
| fn len_bytes(bytes: &[u8]) -> [u8; 4] { |
There was a problem hiding this comment.
Okay, some minor remaining nits: please order these in top-down fashion; first the #[test] functions, then connect_with_chunks(). Suggest inlining len_bytes() and changing greeting to be a const (this should be at the bottom).
|
I encountered this approx. at the same time and would have filed a PR fixing this if I had not found this PR at the time. Could we move this forward so I can drop my own fix. |
|
Send your own PR with a clean commit history, keep the author of this PR as author or co-author of commits where that makes sense. |
Apologies I missed the above response. I'll get those changes in today. |
Thank you! |
When EPP responses arrived in multiple chunks, the read counter would reset to its previous value instead of accumulating, causing spurious "Unexpected EOF while reading" errors. The connection state machine's pattern destructuring copied state fields instead of mutating them, so increments to the read counter were lost when the original state was returned. Construct the next state with the updated counter instead. Adds test coverage for single and multi-chunk greeting reads.
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: