iced-rs/iced · error

Encode input message

Error message

Encode input message

What it means

The beacon crate's own `send` (the side that pushes `client::Command`s over the length-prefixed TCP protocol) bincode-serializes the command and aborts on encoder failure via `.expect("Encode input message")`. As on the client side, bincode only errors when the `Serialize` implementation of `Command` itself fails, so this guards an internal protocol invariant rather than any I/O condition.

Source

Thrown at beacon/src/lib.rs:301

    stream: &mut net::tcp::OwnedReadHalf,
    buffer: &mut Vec<u8>,
) -> Result<client::Message, Error> {
    let size = stream.read_u64().await? as usize;

    if buffer.len() < size {
        buffer.resize(size, 0);
    }

    let _n = stream.read_exact(&mut buffer[..size]).await?;

    Ok(bincode::deserialize(buffer)?)
}

async fn send(
    stream: &mut net::tcp::OwnedWriteHalf,
    command: client::Command,
) -> Result<(), io::Error> {
    let bytes = bincode::serialize(&command).expect("Encode input message");
    let size = bytes.len() as u64;

    stream.write_all(&size.to_be_bytes()).await?;
    stream.write_all(&bytes).await?;
    stream.flush().await?;

    Ok(())
}

async fn delay() {
    tokio::time::sleep(Duration::from_secs(2)).await;
}

View on GitHub (pinned to 2cffa99b39)

Solutions

  1. Fix the `Command` payload type so bincode encodes it cleanly (derive Serialize/Deserialize for every variant)
  2. Map the error into io::Error instead of panicking so the session degrades instead of the process dying
  3. Round-trip test every Command variant in CI
  4. Align iced/beacon versions between both ends of the connection

Example fix

// before
let bytes = bincode::serialize(&command).expect("Encode input message");
// after
let bytes = bincode::serialize(&command)
    .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
Defensive patterns

Strategy: validation

Validate before calling

#[test]
fn beacon_command_roundtrip() {
    for cmd in all_command_variants() { // helper enumerating every client::Command
        let bytes = bincode::serialize(&cmd).expect("serialize");
        let _back: Command = bincode::deserialize(&bytes).expect("deserialize");
    }
}

Prevention

When it happens

Trigger: Sending any `client::Command` once a beacon TCP session is established. The panic occurs when a `Command` variant fails to serialize — typically after the debug protocol gained a payload type with a fallible Serialize impl, or when app and debug tool were built from mismatched iced versions.

Common situations: Adding a new Command variant with non-derived or partially-skipped serialization; protocol drift between the iced version of the app and of the debug UI; running the beacon server on the default 127.0.0.1:9167 while iterating on debug-tool code.

Related errors


AI-assisted analysis of iced-rs/iced@2cffa99b39 (2026-08-16). Data as JSON: /api/errors/30ab56ef3c55941c. Report an issue: GitHub.