Skip to content

The STDIO command creation flags still not working #253

@Pluto-Y

Description

@Pluto-Y

Describe the bug
I create STDIO client using #243 example code, but it still not working in release mode

The code i use:

#[tauri::command]
async fn get_tools(command: &str, args: Vec<String>) -> Result<String, String> {
    let envs = get_login_shell_env()
        .await
        .map_or(HashMap::default(), |envs| envs);

    let mut cmd = process_wrap::tokio::TokioCommandWrap::with_new(command, |cmd| {
        cmd.args(args).envs(&envs);
    });

    cmd.wrap(process_wrap::tokio::KillOnDrop);
    #[cfg(target_os = "windows")]
    cmd.wrap(process_wrap::tokio::CreationFlags(
        windows::Win32::System::Threading::CREATE_NO_WINDOW,
    ));

    let transport = TokioChildProcess::new(cmd).unwrap();
    let service = ().serve(transport).await.unwrap();

    let tools = service.list_tools(Default::default()).await.unwrap();
    log::info!("Available tools: {tools:#?}");

    tokio::spawn(async move {
        // mock service still running for a while
        tokio::time::sleep(Duration::from_secs(60)).await;
        if let Err(err) = service.cancel().await {
            log::error!("Failed to cancel service: {err}");
            return;
        };

        log::info!("Service cancelled after timeout");
    });

    Ok(serde_json::to_string(&tools).unwrap_or_else(|_| {
        log::error!("Failed to serialize tools");
        "[]".to_string()
    }))
}

When the running service is created, the system terminal window still be created

Image

PS: when i try to comment the code command_wrap.wrap(process_wrap::tokio::JobObject); in TokioChildProcess, it can be work

To Reproduce
Steps to reproduce the behavior:

  1. using the above codes and run in release mode

Expected behavior
A clear and concise description of what you expected to happen.

DO NOT create a terminal window

Logs
If applicable, add logs to help explain your problem.

Additional context
Add any other context about the problem here.

If you need demo, i can supply it

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-bugBug fixes and error corrections

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions