vectordotdev/vector · error
This can't fail because the inner writer is a Vec
Error message
This can't fail because the inner writer is a Vec
What it means
A panic assertion on `GzEncoder::finish()` inside `Buffer::finish()`. flate2's `finish()` returns `io::Result`, but the error variant only occurs when writing the compressed tail to the underlying writer fails. Here the underlying writer is an in-memory `Vec`-backed `BytesMut` writer, which cannot fail, so Vector asserts the invariant with `.expect`. This panic firing means the in-memory write failed — an internal invariant violation, not a user-facing error.
Solutions
- Ensure the process has adequate memory headroom; this failure implies allocation failure, not data or config problems.
- If it reproduces, check system memory limits (container cgroup limits) and increase them.
- Report to Vector maintainers as an invariant violation if it fires without memory pressure.
Defensive patterns
Strategy: fallback
Try / catch
// Cannot be caught as an error; guard at the topology level:
std::panic::catch_unwind(|| buffer.finish())
.map_err(|_| ())
.unwrap_or_else(|_| fallback_plain_buffer()), // drop to uncompressed retry Prevention
- Ensure the host/container has memory headroom well above batch buffer sizes (batch.max_bytes).
- Avoid extremely large batch settings that force big buffer growths at finish time.
- Monitor container OOM/pressure metrics alongside Vector panics.
When it happens
Trigger: Calling `Buffer::finish()` on a buffer initialized with `Compression::Gzip` when `GzEncoder::finish` returns Err — only possible if the inner `bytes::buf::Writer<BytesMut>` write fails, e.g. on memory allocation failure when growing the buffer.
Common situations: Under extreme memory pressure/OOM conditions when the buffer tries to grow while flushing the gzip footer; otherwise essentially never hit in normal operation regardless of sink configuration.
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
- Zstd encoder should not fail on init.
- can't run runner twice
- failed to finish encoder
AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16).
Data as JSON: /api/errors/f8743c8d4510ad6a.
Report an issue: GitHub.
Appendix: source
Thrown at src/sinks/util/buffer/mod.rs:140
self.num_items >= self.settings.events || new_bytes >= self.settings.bytes,
)
}
}
fn is_empty(&self) -> bool {
self.is_empty()
}
fn fresh(&self) -> Self {
Self::new(self.settings, self.compression)
}
fn finish(self) -> Self::Output {
match self.inner {
Some(InnerBuffer::Plain(inner)) => inner.into_inner(),
Some(InnerBuffer::Gzip(inner)) => inner
.finish()
.expect("This can't fail because the inner writer is a Vec")
.into_inner(),
Some(InnerBuffer::Zlib(inner)) => inner
.finish()
.expect("This can't fail because the inner writer is a Vec")
.into_inner(),
Some(InnerBuffer::Zstd(inner)) => inner
.finish()
.expect("This can't fail because the inner writer is a Vec")
.into_inner(),
Some(InnerBuffer::Snappy(inner)) => inner
.finish()
.expect("This can't fail because the inner writer is a Vec")
.into_inner(),
None => BytesMut::new(),
}
}
fn num_items(&self) -> usize {View on GitHub (pinned to bdb87aeaa4)