vectordotdev/vector · error
zlib writer should not fail to finish
Error message
zlib writer should not fail to finish
What it means
A panic assertion on `ZlibEncoder::finish()` in `Writer::into_inner` (compressor.rs). The zlib stream trailer is written into an in-memory `BytesMut` writer that cannot fail, so Vector asserts completion. A panic would mean the in-memory write failed during stream finalization — an internal invariant violation such as allocation failure.
Solutions
- Raise process/container memory limits.
- Switch to the fallible `Writer::finish()` API which propagates errors as `io::Result`.
- File a Vector bug if the panic reproduces without memory pressure.
Defensive patterns
Strategy: try-catch
Try / catch
let finished = writer.into_inner()?.finish()?; // io::Result propagated, no panic
Prevention
- Propagate io::Result instead of asserting on zlib stream finalization.
- Monitor memory usage of sinks configured with compression: zlib.
- Test sink payloads near batch.max_bytes limits to catch growth failures early.
When it happens
Trigger: Calling `Writer::into_inner()` with `Compression::Zlib` when `ZlibEncoder::finish` returns Err while finalizing the compressed stream.
Common situations: Rare; effectively only under memory pressure while finalizing a zlib-compressed sink payload.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- BufWriter writer should not fail to finish
- gzip writer should not fail to finish
- snappy writer should not fail to finish
- This can't fail because the inner writer is a Vec
- Zstd encoder should not fail on init.
AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16).
Data as JSON: /api/errors/44227c371a257b10.
Report an issue: GitHub.
Appendix: source
Thrown at src/sinks/util/compressor.rs:44
Writer::Zlib(inner) => inner.get_ref().get_ref().get_ref(),
Writer::Zstd(inner) => inner.get_ref().get_ref(),
Writer::Snappy(inner) => inner.get_ref().get_ref(),
}
}
pub fn into_inner(self) -> BytesMut {
match self {
Writer::Plain(writer) => writer,
Writer::Gzip(writer) => writer
.into_inner()
.expect("BufWriter writer should not fail to finish")
.finish()
.expect("gzip writer should not fail to finish"),
Writer::Zlib(writer) => writer
.into_inner()
.expect("BufWriter writer should not fail to finish")
.finish()
.expect("zlib writer should not fail to finish"),
Writer::Zstd(writer) => writer
.finish()
.expect("zstd writer should not fail to finish"),
Writer::Snappy(writer) => writer
.finish()
.expect("snappy writer should not fail to finish"),
}
.into_inner()
}
pub fn finish(self) -> io::Result<BytesMut> {
let buf = match self {
Writer::Plain(writer) => writer,
Writer::Gzip(writer) => writer.into_inner()?.finish()?,
Writer::Zlib(writer) => writer.into_inner()?.finish()?,
Writer::Zstd(writer) => writer.finish()?,
Writer::Snappy(writer) => writer.finish()?,
}View on GitHub (pinned to bdb87aeaa4)