rustfs/rustfs · error · io::Error

unexpected EOF while reading S2 chunk header

Error message

unexpected EOF while reading S2 chunk header

What it means

S2 decompression stream ended before the fixed-length chunk header (type + 24-bit length + CRC) was fully read. Fires in rio-v2's async poll loop when the compressed input is truncated at a chunk boundary.

Source

Thrown at crates/rio-v2/src/compress_reader.rs:318

        loop {
            if *this.finished {
                return Poll::Ready(Ok(()));
            }

            if !*this.reading_chunk {
                while *this.header_read < CHUNK_HEADER_LEN {
                    let mut read_buf = ReadBuf::new(&mut this.header_buf[*this.header_read..]);
                    match this.inner.as_mut().poll_read(cx, &mut read_buf) {
                        Poll::Pending => return Poll::Pending,
                        Poll::Ready(Ok(())) => {
                            let n = read_buf.filled().len();
                            if n == 0 {
                                if *this.header_read == 0 {
                                    *this.finished = true;
                                    return Poll::Ready(Ok(()));
                                }
                                return Poll::Ready(Err(io::Error::new(
                                    io::ErrorKind::UnexpectedEof,
                                    "unexpected EOF while reading S2 chunk header",
                                )));
                            }
                            *this.header_read += n;
                        }
                        Poll::Ready(Err(err)) => return Poll::Ready(Err(err)),
                    }
                }

                *this.chunk_type = this.header_buf[0];
                *this.chunk_len =
                    (this.header_buf[1] as usize) | ((this.header_buf[2] as usize) << 8) | ((this.header_buf[3] as usize) << 16);
                *this.header_read = 0;

                if this.chunk_buf.len() < *this.chunk_len {
                    this.chunk_buf.resize(*this.chunk_len, 0);
                }

View on GitHub (pinned to 35af688cd9)

Solutions

  1. Fail with UnexpectedEof and heal the object
  2. Verify complete chunk writes were committed
  3. Retry the read from a healthy replica
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at crates/rio-v2/src/compress_reader.rs:318 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of rustfs/rustfs@35af688cd9 (2026-08-20). Data as JSON: /api/errors/c8ec7276ca592ca2. Report an issue: GitHub.