Skip to content

[bug] Buffer of Reciever<CommandEvent> from Command::new_sidecar::spawn clogs if events go unhandeled #2152

Open
@bicarlsen

Description

@bicarlsen

Describe the bug

We spawn a database instance using Command::new_sidecar::spawn, which returns a [Receiver](https://docs.rs/tauri/latest/tauri/async_runtime/struct.Receiver.html)<[CommandEvent](https://docs.rs/tauri/latest/tauri/api/process/enum.CommandEvent.html)>. If the Receiver is not dropped, but the CommandEvents go unhandled, it seems a buffer fills up, eventually causing the sidecar process to crash. e.g.

let Some(_rx, _) = tauri::api::process::Command::new_sidecar("my_db").unwrap().spawn().unwrap();

If we consume the events, the issue is resolved. e.g.

let Some(mut rx, _) = tauri::api::process::Command::new_sidecar("my_db").unwrap().spawn().unwrap();
tauri::async_runtime::spawn(async move {
      while let Some(event) = rx.recv().await {}
});

Reproduction

No response

Expected behavior

No response

Platform and versions

[✔] Environment
    
OS: Mac OS 13.0.0 X64
  ✔ Xcode Command Line Tools: installed
  ✔ rustc: 1.67.0-nightly (95a3a7277 2022-10-31)
  ✔ Cargo: 1.67.0-nightly (7e484fc1a 2022-10-27)
  ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
  ✔ Rust toolchain: nightly-2022-11-01-aarch64-apple-darwin (environment override by RUSTUP_TOOLCHAIN)
node: 18.6.0
npm: 8.13.2

[-] Packages
    
tauri [RUST]: 1.3.0
tauri-build [RUST]: 1.2.1
wry [RUST]: 0.24.3
tao [RUST]: 0.16.2
@tauri-apps/api [NPM]: not installed!
@tauri-apps/cli [NPM]: 1.3.1

[-] App
    
build-type: bundle
CSP: unset
distDir: ../dist
devPath: http://localhost:1420/

Stack trace

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    📬Proposal

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions