tauri-apps / tauri-apps/plugins-workspace
[bug] Buffer of `Reciever<CommandEvent>` from `Command::new_sidecar::spawn` clogs if events go unhandeled
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 602
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 9
Description
### Describe the bug
We spawn a database instance using [`Command::new_sidecar::spawn`](https://docs.rs/tauri/latest/tauri/api/process/struct.Command.html#method.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 `CommandEvent`s go unhandled, it seems a buffer fills up, eventually causing the sidecar process to crash. e.g.
```rust
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.
```rust
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
```text
[✔] 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_
Contributor guide
Assessment
This issue has not been assessed yet.