Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Command::output() never executes/completes in async commands #3505

Closed
FabianLars opened this issue Feb 18, 2022 · 4 comments
Closed

[bug] Command::output() never executes/completes in async commands #3505

FabianLars opened this issue Feb 18, 2022 · 4 comments
Assignees

Comments

@FabianLars
Copy link
Member

Describe the bug

If you try to execute a sidecar or Commands in general in an async command it never drives to completion (or probably doesn't even start in the first place).

I tested this only on windows, but according to discord it's a problem on linux or macOS too (can't remember which one they had)

Reproduction

Create a simple async command (I'm using windows for this example):

#[tauri::command]
async fn list_dir() {
    let c = Command::new("powershell.exe").args(["ls"]);
    dbg!(c.output().unwrap());
}

It works if you remove the async keyword. Same if you use (the underlying) std::process::Command::output().
Command::spawn() works fine fwiw.

Expected behavior

No response

Platform and versions

Operating System - Windows, version 10.0.19044 X64
Webview2 - 98.0.1108.55
Visual Studio Build Tools:
   - Visual Studio Build Tools 2022

Node.js environment
  Node.js - 16.14.0
  @tauri-apps/cli - 1.0.0-rc.5
  @tauri-apps/api - 1.0.0-rc.1

Global packages
  npm - 8.3.1
  pnpm - 6.31.0
  yarn - Not installed

Rust environment
  rustup - 1.24.3
  rustc - 1.58.1
  cargo - 1.58.0
  toolchain - stable-x86_64-pc-windows-msvc 

App directory structure
/dist
/node_modules
/src
/src-tauri

App
  tauri - 1.0.0-rc.3 (no lockfile)
  tauri-build - no manifest (no lockfile)
  tao - no manifest (no lockfile)
  wry - no manifest (no lockfile)
  build-type - bundle
  CSP - default-src 'self'
  distDir - ../dist
  devPath - http://localhost:3000/
  framework - React

Stack trace

No response

Additional context

No response

@JonasKruckenberg
Copy link
Contributor

For context the discord thread: https://discord.com/channels/616186924390023171/731495047962558564/944170846707122216

Do we have any ideas why this may be happening? Command::spawn works like a charm so it's the output method that is the problem?

@lucasfernog
Copy link
Member

It's probably the safe_block_on implementation.

@lucasfernog
Copy link
Member

I think we can refactor the Command APIs a little bit and make them async instead, and offer blocking variants similar to what we did for the dialog APIs.

@lucasfernog
Copy link
Member

First I'll try to fix the safe_block_on impl since that one is used on other places too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants