Repository navigation
desktop-app: Windows kill_running_daemon targets edition-correct binary name - #2140
Conversation
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]>
|
APPROVE Adversarial review (independent sub-agent) ran, found no BLOCKERs. It confirmed:
It raised two SHOULD-FIX items, both addressed in the current HEAD:
It also surfaced a genuine, separate, pre-existing caveat: whether the installed Windows daemon binary actually carries a Self-approving per standing merge authorization (core requires adversarial re-review before self-merge, which is complete above). |
… 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]>
What this fixes
Closes #2138.
kill_running_daemon(Windows variant,packages/desktop-app/src-tauri/src/daemon_setup.rs) hardcodedtaskkill /F /IM nodespaced.exeregardless of edition.daemon_binary_name()(same file) already correctly resolves tonodespaced-profor a Pro build, butkill_running_daemonnever used it — so on a Pro build running on Windows, this taskkill would never match the actual runningnodespaced-pro.exeprocess. The macOS/Linuxkill_running_daemonvariants don't have this bug: they already resolve the installed binary's full path viadaemon_binary_name()and verify each candidate PID'sargv[0]against it.What changed
daemon_binary_name()'s edition-selection body into a puredaemon_binary_name_for(is_pro: bool) -> &'static str, withdaemon_binary_name()now just callingdaemon_binary_name_for(is_pro_build()). Zero behavior change for any of its five existing callers — confirmed each still receives the identical output.daemon_image_name_for(is_pro: bool) -> String(#[cfg(any(windows, test))], mirroring the existingdaemon_log_paths/open_daemon_logpattern in this file), returningformat!("{}.exe", daemon_binary_name_for(is_pro)).kill_running_daemon(Windows) now callsdaemon_image_name_for(is_pro_build())instead of the hardcoded literal, for both thetaskkillargs and the log line.#[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(nativeaarch64-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.cargo check --target x86_64-pc-windows-msvc -p nodespace-app --libstill 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.#[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 notauri/ringin its dependency tree, and ran bothcargo check --target x86_64-pc-windows-msvcandcargo clippy --target x86_64-pc-windows-msvc --all-targets -- -D warningsagainst it — both clean.Not verified, and cannot be from here: that a real
taskkill /F /IM nodespaced-pro.exeactually matches and kills a live Pro-edition daemon process on Windows. This depends on the installed daemon binary genuinely carrying a.exeextension 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 beforekill_running_daemonis 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 Unixkill_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.cargo check/cargo clippy --target x86_64-pc-windows-msvcon the changed Windows functions — clean.bun run test:all, Rust workspace tests, e2e) — all green.taskkillruntime behavior against a realnodespaced-pro.exeprocess (no Windows machine available).🤖 Generated with Claude Code