valeriansaliou/sonic · error · std::io::Error
Command too long. Max buffer size: {}
Error message
Command too long. Max buffer size: {} What it means
The client's Channel::send returns an std::io::Error of kind InvalidInput when the serialized command exceeds channel_info.buffer_size, the negotiated maximum line buffer for this channel. The command is rejected locally without touching the network.
Source
Thrown at client/src/channel.rs:115
multiplexer.attach(conn)?;
Ok(Self {
server_info,
channel_info,
dispatcher_tx: tx,
poll_waker: Arc::clone(&multiplexer.poll_waker),
is_closed: false,
})
}
pub(crate) fn send<T: Send + 'static>(
&self,
command: Command,
discriminant: Mode::Discriminant,
parse: impl Fn(&str) -> std::io::Result<T> + Send + 'static,
) -> std::io::Result<oneshot::Receiver<std::io::Result<T>>> {
if command.len() > self.channel_info.buffer_size {
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!(
"Command too long. Max buffer size: {}",
self.channel_info.buffer_size
),
));
}
let (tx, rx) = oneshot::channel();
self.dispatcher_tx
.send_timeout(
Task {
command,
discriminant,
callback: Box::new(move |result| {
// log_debug!("Callback");
View on GitHub (pinned to e6a72da6a5)
Solutions
- Check command length before sending and split payloads into chunks under buffer_size
- Increase the channel buffer size if the client/server configuration allows it
- Truncate or preprocess input to a safe maximum length
- Handle the io::ErrorKind::InvalidInput error in send_buffered callers and surface a clear message
Example fix
// client
// before
channel.send(Command::push(collection, bucket, huge_text), disc, parse)?;
// after
if huge_text.len() > channel.buffer_size() {
return Err(...); // or split into chunks
}
channel.send(Command::push(collection, bucket, huge_text), disc, parse)?; Defensive patterns
Strategy: validation
Validate before calling
if command.len() > channel.buffer_size() {
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"command exceeds channel buffer size; split the payload",
));
} Try / catch
match channel.send(cmd, disc, parse) {
Err(e) if e.kind() == std::io::ErrorKind::InvalidInput => {
// split into chunks and resend
}
other => other?,
} Prevention
- Cap user-supplied text length before building commands
- Chunk payloads to fit buffer_size
- Keep client and server buffer settings in sync
When it happens
Trigger: Calling send (directly or via send_buffered) with a Command whose byte length exceeds self.channel_info.buffer_size — e.g. a PUSH/QUERY payload larger than the channel's buffer size.
Common situations: Indexing documents larger than the client/server buffer; constructing commands with unbounded user input; mismatch between client buffer_size and the payload sizes the application assumes.
Understand the failure class
Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.
Related errors
AI-assisted analysis of valeriansaliou/sonic@e6a72da6a5 (2026-09-01).
Data as JSON: /api/errors/b1d14ebf17cd088e.
Report an issue: GitHub.