tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
79.51k stars 2.36k forks source link

[bug] nsis installer won't stop spawned sidecar when upgrading #9950

Open vangork opened 1 month ago

vangork commented 1 month ago

Describe the bug

If the tauri app is runing with a spawned background sidecar process, when clicking the nsis bundle to upgrade the tauri app it would pop up a window asking to close the tauri app("xxx is runing. Click OK to close it"). But the spawned sidecar process won't be terminated after the OK button is clicked.

Shall we call tauri cleanup so that "RunEvent::Exit" or "RunEvent::ExitRequest" event handler could be called, or call "taskkill /f /t " to terminate the tauri app process tree so that all the child process would be killed together like described in https://github.com/electron-userland/electron-builder/issues/2516.

Reproduction

No response

Expected behavior

No response

Full tauri info output

$ tauri info

[✔] Environment
    - OS: Windows 10.0.22631 X64
    ✔ WebView2: 125.0.2535.79
    ✔ MSVC: Visual Studio Build Tools 2022
    ✔ rustc: 1.76.0 (07dca489a 2024-02-04)
    ✔ cargo: 1.76.0 (c84b36747 2024-01-18)
    ✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 18.18.2
    - yarn: 1.22.21
    - npm: 9.8.1

[-] Packages
    - tauri [RUST]: 2.0.0-beta.22
    - tauri-build [RUST]: 2.0.0-beta.17
    - wry [RUST]: 0.40.0
    - tao [RUST]: 0.28.0
    - @tauri-apps/api [NPM]: 2.0.0-beta.13
    - @tauri-apps/cli [NPM]: 2.0.0-beta.17

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: Vue.js
    - bundler: Vite
Done in 83.82s.

Stack trace

No response

Additional context

No response

Legend-Master commented 4 weeks ago

Just a reference, some thoughts from https://github.com/tauri-apps/plugins-workspace/issues/1014

vangork commented 4 weeks ago

I am not using the updater plugin to download and install the update implicitly but just use the plugin to check update availability and guide users to download the nsis bundle from external browser and install explicitly. In this case, the termination would need to be sent from nsis bundle intead of the updater plugin. @Legend-Master

Legend-Master commented 4 weeks ago

Yeah, I was thinking the same, for a graceful shutdown, we need some way of communicating between the installer and the app to do that, or maybe just kill all the child processes for a quick fix (do it in nsis or change side car to use Job Object)