Skip to content

feat: allow collecting raw output from sidecars #3090

Open

Description

@niusia-ua

In the tauri_plugin_shell::process::Command, we have the output method which automatically collects all output from the sidecar command. The issue with it is that it inserts \n after each received chunk. In case of handling raw output (i.e. binary output; for example, images, PDFs, etc.), this behavior breaks the received buffer.

It would be nice to have a boolean parameter or a separate method for collecting the output without inserting \n between chunks.

pub async fn output(self) -> crate::Result<Output> {
let (mut rx, _child) = self.spawn()?;
let mut code = None;
let mut stdout = Vec::new();
let mut stderr = Vec::new();
while let Some(event) = rx.recv().await {
match event {
CommandEvent::Terminated(payload) => {
code = payload.code;
}
CommandEvent::Stdout(line) => {
stdout.extend(line);
stdout.push(NEWLINE_BYTE);
}
CommandEvent::Stderr(line) => {
stderr.extend(line);
stderr.push(NEWLINE_BYTE);
}
CommandEvent::Error(_) => {}
}
}
Ok(Output {
status: ExitStatus { code },
stdout,
stderr,
})
}

Activity

  1. Tunglies commented on Dec 4, 2025

    @Tunglies
    Contributor
    pub fn spawn(self) -> crate::Result<(Receiver<CommandEvent>, CommandChild)> {
            let raw = self.raw_out;
            ...
    }
    /// impl Command
    pub fn set_raw_out(mut self, raw_out: bool) -> Self {
            self.raw_out = raw_out;
            self
        }

    Seemed we already have boolean to determine formating.

  2. niusia-ua commented on Dec 4, 2025

    @niusia-ua
    ContributorAuthor

    This option only controls the reading method, but the output method still adds newlines.
    However, this option is indeed helpful - I use it in my custom stdout/stderr handlers.

    If I understand it correctly, when we process a text output with raw = false, the output method reads the output line by line and inserts newlines after each line. And with raw = true, it reads the output as is but still inserts newlines after each chunk.

  3. FabianLars commented on Dec 4, 2025

    @FabianLars
    Member

    And with raw = true, it reads the output as is but still inserts newlines after each chunk.

    as far as i understand #1231 that's not supposed to happen (or: the reason why raw=true was added in the first place)

  4. added a commit that references this issue on Nov 3, 2026
    076ef2f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions