zellij-org/zellij · error

Failed to convert to protobuf: {:?}

Error message

Failed to convert to protobuf: {:?}

What it means

In close_plugin (wasm_bridge.rs), the hardcoded Event::BeforeClose must be converted to ProtobufEvent before being written into the plugin's WASI stdin. This error means that conversion failed, so the plugin never receives its BeforeClose update during teardown.

Source

Thrown at zellij-server/src/plugins/wasm_bridge.rs:2191

        plugin_id,
        loading_indication,
    ));
}

pub fn apply_before_close_event_to_plugin(
    plugin_id: PluginId,
    client_id: ClientId,
    running_plugin: &mut RunningPlugin,
    senders: ThreadSenders,
) -> Result<()> {
    let instance = &running_plugin.instance;

    let err_context = || format!("Failed to apply event to plugin {plugin_id}");
    let event = Event::BeforeClose;
    let protobuf_event: ProtobufEvent = event
        .clone()
        .try_into()
        .map_err(|e| anyhow!("Failed to convert to protobuf: {:?}", e))?;
    let update = instance
        .get_typed_func::<(), i32>(&mut running_plugin.store, "update")
        .with_context(err_context)?;
    wasi_write_object(running_plugin.store.data(), &protobuf_event.encode_to_vec())
        .with_context(err_context)?;
    let _should_render = update
        .call(&mut running_plugin.store, ())
        .with_context(err_context)?;
    let pipes_to_block_or_unblock = pipes_to_block_or_unblock(running_plugin, None);
    let plugin_render_asset =
        PluginRenderAsset::new(plugin_id, client_id, vec![]).with_pipes(pipes_to_block_or_unblock);
    let _ = senders
        .send_to_plugin(PluginInstruction::UnblockCliPipes(vec![
            plugin_render_asset,
        ]))
        .context("failed to unblock input pipe");
    Ok(())
}

View on GitHub (pinned to 98a0837077)

Solutions

  1. Rebuild zellij from a clean tree so Event and ProtobufEvent come from the same source version
  2. If you are developing zellij itself, implement/derive the TryFrom<Event> mapping for the new variant
  3. Restart the session; a one-off occurrence during shutdown does not corrupt state, the plugin is unloaded anyway
Defensive patterns

Strategy: try-catch

Try / catch

let protobuf_event: ProtobufEvent = Event::BeforeClose.clone().try_into()
    .with_context(|| format!("Failed to apply event to plugin {plugin_id}"))?;

Prevention

When it happens

Trigger: Effectively an internal invariant break: Event::BeforeClose gains a field that ProtobufEvent conversion rejects, or the protobuf event enum drifts out of sync with the Rust Event enum across versions. Not caused by user data.

Common situations: Mixed zellij/protobuf versions after a partial upgrade or stale build artifacts; contributing code that adds an Event variant without a protobuf mapping.

Related errors


AI-assisted analysis of zellij-org/zellij@98a0837077 (2026-08-16). Data as JSON: /api/errors/1c90de847b69328a. Report an issue: GitHub.