Skip to content

desktop-app: Windows kill_running_daemon targets edition-correct binary name - #2140

Merged
mstomar125 merged 1 commit into
mainfrom
issue-2138-windows-pro-kill
Aug 18, 2026
Merged

mstomar125 merged 1 commit into
mainfrom
issue-2138-windows-pro-kill

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

What this fixes

Closes #2138. kill_running_daemon (Windows variant, packages/desktop-app/src-tauri/src/daemon_setup.rs) hardcoded taskkill /F /IM nodespaced.exe regardless of edition. daemon_binary_name() (same file) already correctly resolves to nodespaced-pro for a Pro build, but kill_running_daemon never used it — so on a Pro build running on Windows, this taskkill would never match the actual running nodespaced-pro.exe process. The macOS/Linux kill_running_daemon variants don't have this bug: they already resolve the installed binary's full path via daemon_binary_name() and verify each candidate PID's argv[0] against it.

What changed

  • Extracted daemon_binary_name()'s edition-selection body into a pure daemon_binary_name_for(is_pro: bool) -> &'static str, with daemon_binary_name() now just calling daemon_binary_name_for(is_pro_build()). Zero behavior change for any of its five existing callers — confirmed each still receives the identical output.
  • Added daemon_image_name_for(is_pro: bool) -> String (#[cfg(any(windows, test))], mirroring the existing daemon_log_paths/open_daemon_log pattern in this file), returning format!("{}.exe", daemon_binary_name_for(is_pro)).
  • kill_running_daemon (Windows) now calls daemon_image_name_for(is_pro_build()) instead of the hardcoded literal, for both the taskkill args and the log line.
  • Two new #[test]s pin the exact expected image name for both editions (community: nodespaced.exe, Pro: nodespaced-pro.exe) — these are pure-function tests, runnable on any platform, no separate Pro/community build needed.

Verification — what could and couldn't be checked here

This machine is macOS-only, no Windows box/VM, matching the situation in #2129/#2137. Mirroring that PR's verification approach:

  • cargo check -p nodespace-app --lib (native aarch64-apple-darwin) — clean.
  • cargo test -p nodespace-app --lib daemon_setup — 8/8 pass (2 new, existing macOS codesign + Windows-stdio tests unaffected).
  • cargo clippy -p nodespace-app --all-targets -- -D warnings — clean.
  • cargo fmt -p nodespace-app -- --check — clean.
  • Confirmed a full cargo check --target x86_64-pc-windows-msvc -p nodespace-app --lib still fails the same pre-existing, unrelated way as in 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's C build needs a Windows SDK/MSVC toolchain not present here.
  • To get real signal on the actual changed code, copied the new/changed #[cfg(windows)] functions (kill_running_daemon, check_daemon_socket, daemon_image_name_for, daemon_binary_name_for, DaemonStatus) verbatim into an isolated scratch crate with no tauri/ring in its dependency tree, and ran both cargo check --target x86_64-pc-windows-msvc and cargo clippy --target x86_64-pc-windows-msvc --all-targets -- -D warnings against it — both clean.

Not verified, and cannot be from here: that a real taskkill /F /IM nodespaced-pro.exe actually matches and kills a live Pro-edition daemon process on Windows. This depends on the installed daemon binary genuinely carrying a .exe extension on disk — which this PR inherits as an assumption from the literal it replaces (the original code already assumed .exe; this PR does not introduce that assumption, only the edition-awareness). An adversarial review of this PR additionally surfaced a plausible-but-unconfirmed separate, pre-existing inconsistency: resolve_sidecar_path's Windows resource lookup (binaries/{name}-{triple}, no .exe) vs. what CI actually names the built Windows sidecar artifact (binaries/nodespaced-{triple}.exe, with .exe) — if real, that could mean the Windows sidecar-extraction step fails before kill_running_daemon is ever reached at all. That's out of scope for this narrow, one-line-class fix and unconfirmed without a real Windows run, so I'm not attempting to fix it here — I'm folding it into #2137's existing Windows live-validation checklist (which already tracks this same file's Windows code paths) rather than opening a duplicate issue.

Given the fix itself is small, strictly improves on the pre-existing hardcoded literal, doesn't regress any other caller of daemon_binary_name(), and mirrors an already-correct pattern in the same file (the Unix kill_running_daemon), I have reasonable confidence merging this now, while leaving live Windows validation tracked on #2137 rather than blocking the merge on it.

Testing

  • cargo test -p nodespace-app --lib daemon_setup — 8/8 pass.
  • cargo clippy -p nodespace-app --all-targets -- -D warnings — clean.
  • cargo fmt -p nodespace-app -- --check — clean.
  • Isolated scratch-crate cargo check/cargo clippy --target x86_64-pc-windows-msvc on the changed Windows functions — clean.
  • Full pre-push gate (bun run test:all, Rust workspace tests, e2e) — all green.
  • Not tested: actual taskkill runtime behavior against a real nodespaced-pro.exe process (no Windows machine available).

🤖 Generated with Claude Code

kill_running_daemon (Windows) hardcoded taskkill /IM nodespaced.exe,
which only matches the community edition. A Pro build's running
nodespaced-pro.exe was never matched, so a stale Pro daemon would
survive a sidecar update instead of being killed before the updated
binary launches.

Extracts daemon_binary_name()'s edition-selection logic into a pure
daemon_binary_name_for(is_pro: bool) helper, and adds
daemon_image_name_for(is_pro: bool) -> String (".exe"-suffixed) that
kill_running_daemon now uses to build the taskkill image name. Both
helpers are directly unit-testable on any platform, covering both
editions' exact expected strings without needing separate Pro/
community builds.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

APPROVE

Adversarial review (independent sub-agent) ran, found no BLOCKERs. It confirmed:

  • The daemon_binary_name() → daemon_binary_name_for() refactor is behavior-preserving for all five existing callers.
  • The #[cfg(any(windows, test))] gating matches the file's existing daemon_log_paths/open_daemon_log pattern, no dead-code risk.
  • &image_name (String) deref-coerces correctly in the taskkill args array — verified with a standalone repro.
  • Independently re-ran cargo fmt --check, cargo check --lib, cargo clippy --all-targets -- -D warnings, cargo test --lib daemon_setup — all pass.

It raised two SHOULD-FIX items, both addressed in the current HEAD:

  1. A tautological third test that asserted the function against its own body (couldn't have caught the actual bug class) — removed.
  2. Imprecise doc wording (a comment said "not #[cfg(windows)]-gated" for a function that is gated on any(windows, test); another referenced daemon_binary_name() where daemon_binary_name_for() is what's actually tested) — corrected.

It also surfaced a genuine, separate, pre-existing caveat: whether the installed Windows daemon binary actually carries a .exe extension on disk, and a possible mismatch between resolve_sidecar_path's resource lookup and what CI names the Windows sidecar artifact. Neither is introduced by this PR (the .exe assumption is inherited unchanged from the literal being replaced), and confirming/denying either needs a real Windows box — folding into #2137's existing Windows-validation checklist rather than blocking this narrow fix.

Self-approving per standing merge authorization (core requires adversarial re-review before self-merge, which is complete above).

@mstomar125
mstomar125 merged commit 5140f4b into main Aug 18, 2026
@mstomar125
mstomar125 deleted the issue-2138-windows-pro-kill branch August 18, 2026 09:33
mstomar125 added a commit that referenced this pull request Sep 14, 2026
… log files (closes #2137) (#2614)

Real-Windows validation of PR #2136/#2140's daemon stderr-to-file fix
surfaced a genuine bug: extract_sidecar_if_changed installed the daemon
binary under ~/.nodespace/bin/ using the bare daemon_binary_name()
("nodespaced"), never routed through bundled_sidecar_name(), so the
extracted file carried no .exe extension. The daemon still spawned (a
literal existing path resolves via Command::new even without an
extension), but registered in the Windows process table under the bare
image name, so kill_running_daemon's taskkill /IM nodespaced.exe never
matched it -- confirmed live on a Windows box: taskkill reported
"process not found" while the real process kept running, for both
community and Pro edition names. A restart could therefore never kill
the previous daemon before spawning a new one.

Fix: route both the install destination (extract_sidecar_if_changed)
and the launch/kill path (ensure_daemon_running's daemon_bin) through a
single new sidecar_install_path() helper, so they can't drift apart
again. Everything else in the daemon stderr-to-file path -- log file
creation/append, handle inheritance into a DETACHED_PROCESS |
CREATE_NEW_PROCESS_GROUP child, append-not-truncate across a simulated
restart, and the real SchemaNode::from_node fields-parse diagnostic
landing in nodespaced-error.log -- verified working as-is on the same
Windows box.

Separately, add a fix for the GUI process's own console-less stderr
(schemas.rs's two direct SchemaNode::from_node calls, discarded by
windows_subsystem = "windows" in release builds): redirect this
process's own STD_OUTPUT_HANDLE/STD_ERROR_HANDLE to log files via
SetStdHandle at startup, gated to release-on-Windows so debug builds
keep their attached console. Verified on a real Windows box with a
standalone windows_subsystem = "windows" harness launched with no
inherited stdio: eprintln!/println! output is lost before the
redirect and lands correctly in the log file after it, including the
real SchemaNode::from_node diagnostic on a genuinely malformed schema.

Co-authored-by: Claude Sonnet 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant