Skip to content

Windows: kill_running_daemon hardcodes nodespaced.exe, misses Pro-edition daemon #2138

Closed

Description

@mstomar125

Context

Found during adversarial review of PR #2136 (Windows daemon stdout/stderr routing, core #2129) — pre-existing bug, not introduced by that PR, scoped out of it deliberately to keep the diff narrow.

packages/desktop-app/src-tauri/src/daemon_setup.rs's Windows kill_running_daemon:

#[cfg(windows)]
async fn kill_running_daemon(socket_path: &Path) {
    ...
    let _ = std::process::Command::new("taskkill")
        .args(["/F", "/IM", "nodespaced.exe"])
        .output();
    tracing::info!("Sent taskkill to nodespaced.exe");
    ...
}

This hardcodes the community-edition binary name. But daemon_binary_name() (same file) returns nodespaced-pro for a Pro build:

fn daemon_binary_name() -> &'static str {
    if is_pro_build() {
        PRO_DAEMON_BINARY_NAME  // "nodespaced-pro"
    } else {
        DAEMON_BINARY_NAME      // "nodespaced"
    }
}

So on Windows, kill_running_daemon (called from ensure_daemon_running when binary_updated is true — e.g. after a sidecar update) targets nodespaced.exe by image name regardless of edition. For a Pro build, this taskkill call would silently miss the actual running nodespaced-pro.exe process, meaning the stale daemon never gets killed before the app tries to launch the updated binary.

The macOS/Linux equivalents (kill_running_daemon's Unix variant) don't have this problem — they resolve the installed binary's full path via daemon_binary_name() and verify each candidate PID's argv[0] against it before signalling, so they're edition-correct by construction.

Suggested fix

Use daemon_binary_name() to build the taskkill image name instead of the hardcoded literal, e.g. format!("{}.exe", daemon_binary_name()).

Verification note

This is a Windows-only code path (#[cfg(windows)]); like #2129/#2137, fixing and validating it needs either a real Windows machine or at minimum a working x86_64-pc-windows-msvc cross-compile setup, neither of which is available in the current macOS-only sandbox. The fix itself is a one-line, low-risk change reasoned from the existing daemon_binary_name() helper and requires no new API surface — but confirming taskkill /F /IM nodespaced-pro.exe actually matches and kills the right process still needs a live Pro build on Windows.

Activity

  1. mstomar125 commented on Aug 18, 2026

    @mstomar125
    ContributorAuthor

    Fixed in #2140 (merged). Verification assessment:

    Verified on this machine (macOS, no Windows box):

    • Native cargo check -p nodespace-app --lib, cargo test -p nodespace-app --lib daemon_setup (8/8 pass), cargo clippy -p nodespace-app --all-targets -- -D warnings, cargo fmt --check — all clean.
    • Confirmed a full cargo check --target x86_64-pc-windows-msvc -p nodespace-app --lib still fails for the same pre-existing, unrelated reason as desktop-app: route Windows daemon stdout/stderr to log files (partial fix for #2129) #2136/Windows: live-validate daemon stderr-to-file fix (PR #2136) + fix desktop-app GUI console-less stderr #2137 (ring needs a Windows SDK/MSVC toolchain).
    • Isolated the changed #[cfg(windows)] functions into a scratch crate (no tauri/ring deps) and ran cargo check/cargo clippy --target x86_64-pc-windows-msvc --all-targets -- -D warnings against the real target — both clean, confirming the Windows API usage type-checks.
    • Adversarial sub-agent review found no BLOCKERs; two SHOULD-FIX items (a tautological test, imprecise doc wording) were addressed before merge.

    Not verified, and can't be from here: that taskkill /F /IM nodespaced-pro.exe actually matches and kills a live Pro-edition daemon process on a real Windows machine. I'm reasonably confident in this specific change — it's a narrow one-line-class fix that mirrors an already-correct pattern in the same file (Unix kill_running_daemon) and doesn't regress any other caller of daemon_binary_name() — so I'm closing this rather than leaving it open/Blocked.

    One caveat surfaced during review that's genuinely open: whether the installed Windows daemon binary carries a .exe extension on disk at all (this PR inherits that assumption unchanged from the literal it replaced, doesn't introduce it), plus a possible separate mismatch between resolve_sidecar_path's resource lookup and what CI names the built Windows sidecar. Neither is specific to this fix — both are folded into #2137's existing Windows live-validation checklist rather than tracked here.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions