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

Command stdout is only emitted on child process close #1935

Closed
lucasfernog opened this issue Jun 1, 2021 · 2 comments
Closed

Command stdout is only emitted on child process close #1935

lucasfernog opened this issue Jun 1, 2021 · 2 comments

Comments

@lucasfernog
Copy link
Member

Describe the bug
The tauri::process::Command API has a bug on the tokio mpsc usage: the stdout line is sent on the channel but the receiver only sees the message when the process is terminated.

To Reproduce
Steps to reproduce the behavior:

  1. Open the API example
  2. Click on the shell tab
  3. Run the following command: `node -e "console.log('message'); while(true){}"
  4. You'll see that the output is only seen when you click on the "kill" button

Expected behavior
The stdout line is seen immediately.

@MitchellMonaghan
Copy link

Hi I've been playing with Tauri and there seems to still be a issue with this unless I'm just being dumb. I am running the following in the browser/webview using the typescript api and no stdout or stderr is printed. The close event is fired and a pid is printed.

import * as tauri from '@tauri-apps/api'

try {
      const test = await tauri.path.resolvePath('C:\\Program Files\\Git\\cmd\\git.exe')
      console.log(test)

      const git = new tauri.shell.Command(test, ['status'])
      git.stdout = function (e) {
        console.log(e)
      }
      git.stderr = function (e) {
        console.log(e)
      }
      git.on('close', (arg) => {
        console.log(arg)
      })

      const myProcess = await git.spawn()
      console.log(myProcess)
    } catch (error) {
      console.log(JSON.stringify(error))
    }

@MitchellMonaghan
Copy link

Turns out I'm just a idiot false alarm carry on.

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

2 participants