mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
MsgPack deserializer: improve handling of EOF (#12183)
# Description `rmp_serde` has two kinds of errors that contain I/O errors, and an EOF can occur inside either of them, but we were only treating an EOF inside an `InvalidMarkerRead` as an EOF, which would make sense for the beginning of a message. However, we should also treat an incomplete message + EOF as an EOF. There isn't really any point in reporting that an EOF was received mid-message. This should fix the issue where the `seq_describe_no_collect_succeeds_without_error` test would sometimes fail, as doing a `describe --no-collect` followed by nushell exiting could (but was not guaranteed to) cause this exact scenario. # User-Facing Changes Will probably remove useless `read error` messages from plugins after exit of `nu` # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting
This commit is contained in:
@ -82,17 +82,16 @@ fn rmp_encode_err(err: rmp_serde::encode::Error) -> ShellError {
|
||||
fn rmp_decode_err<T>(err: rmp_serde::decode::Error) -> Result<Option<T>, ShellError> {
|
||||
match err {
|
||||
rmp_serde::decode::Error::InvalidMarkerRead(err)
|
||||
if matches!(err.kind(), ErrorKind::UnexpectedEof) =>
|
||||
{
|
||||
// EOF
|
||||
Ok(None)
|
||||
}
|
||||
rmp_serde::decode::Error::InvalidMarkerRead(_)
|
||||
| rmp_serde::decode::Error::InvalidDataRead(_) => {
|
||||
// I/O error
|
||||
Err(ShellError::IOError {
|
||||
msg: err.to_string(),
|
||||
})
|
||||
| rmp_serde::decode::Error::InvalidDataRead(err) => {
|
||||
if matches!(err.kind(), ErrorKind::UnexpectedEof) {
|
||||
// EOF
|
||||
Ok(None)
|
||||
} else {
|
||||
// I/O error
|
||||
Err(ShellError::IOError {
|
||||
msg: err.to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
// Something else
|
||||
|
Reference in New Issue
Block a user