Skip to content

Fix correctness/robustness gaps in build-windows.ts found by post-merge review - #2635

Merged
mstomar125 merged 1 commit into
mainfrom
issue-1438-followup-review-gaps
Sep 15, 2026
Merged

mstomar125 merged 1 commit into
mainfrom
issue-1438-followup-review-gaps

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

A code-review pass on #2630 (Tier 1/2 local release build scripts, #1438) arrived after that PR had already merged and surfaced 15 findings against the untested-against-a-real-VM Tier 2 path (scripts/build-windows.ts). This PR fixes the 6 that were genuinely real/live bugs, not just style nits:

  1. isVmRunning() swallowed prlctl failures silently — a failed prlctl list --json (e.g. Parallels not running, permission issue) was treated as "VM not running" with no diagnostic, so the script would try to start a VM that might already be in a broken state with zero signal why. Now logs a warning with the underlying error before falling back.
  2. prlctl start was outside the try/finally — if starting the VM itself threw, the finally block's stop-on-exit logic never ran, and the script would exit without ever trying to stop a VM it may have partially started. Moved inside try.
  3. buildRemoteScript's cd was unquoted — the whole script is joined into a single remote shell command line with no further escaping; a REPO_PATH containing a space (a real shape — NODESPACE_WIN_VM_REPO_PATH is operator-configurable, and Git-Bash-style Windows paths like /c/Users/Build Machine/nodespace-core are exactly this) would word-split and fail the build at its very first step. Now cd '${repoPath}'.
  4. copyArtifactsBack() had two compounding scp bugs: the .msi source had no user@host: prefix at all (scp treated it as a local path), and separately, Bun's $ shell tilde-expands an interpolated value that itself starts with ~ against the local host before scp ever sees it — so the default REPO_PATH (~/nodespace-core) silently spliced this Mac's own home directory into what must stay a purely remote path. Fixed by extracting buildScpSources(), which builds the complete user@host:path strings in plain JS before they ever reach the $ template.
  5. envOrDefault used ?? instead of checking for empty string — process.env.X ?? fallback only catches null/undefined, not an explicitly-empty-string override. NODESPACE_WIN_VM_REPO_PATH= (var set but empty — a real shell/CI misconfiguration shape) would silently produce '' instead of falling back to the documented default. Extracted envOrDefault() with an explicit empty-string check and covered it with tests.
  6. Simplified SIDECAR_BINARIES in build-windows-quick.ts from {crate, bin} pairs to a plain string[] — the crate field was unused dead weight left over from an earlier draft.

The other 9 findings from that review were triaged as lower-priority or dormant (style preferences, or defects only reachable once a real Tier 2 VM exists to test against) and left as documented tech debt rather than churned into this PR.

Closes #2634

Test plan

  • Added regression tests in scripts/build-windows.test.ts for envOrDefault (unset / empty-string / real-value), buildRemoteScript quoting (space-in-path case), and buildScpSources (prefix presence, tilde-safety, distinct nsis/msi targets)
  • Full pre-push gate green locally (test:coverage, test:scripts, test:skill, rust:test:workspace, rust:test:core, rust:test:libsql-linked, rust:test:app-units, cargo build --bin nodespaced, test:e2e, cargo test -p nodespace-app --test "*")
  • Tier 2's real remote-build happy path still cannot be exercised end-to-end — no Parallels VM exists on this machine (unchanged from Local release build scripts: macOS native and Windows cross-compile #2630, documented there and in the local-builds doc)

🤖 Generated with Claude Code

…ge review

A code-review pass on #2630 that arrived after it merged found several
genuine gaps in Tier 2's untested-against-a-real-VM path:

- SSH_HOST/SSH_USER/REPO_PATH used `process.env.X ?? fallback`, which only
  catches null/undefined -- an explicitly-empty-string override (a real
  shell/CI misconfiguration shape) silently produced '' instead of the
  documented default. Added envOrDefault() to treat empty-string as unset too.
- isVmRunning()'s JSON.parse had no try/catch, unlike the near-identical
  call in checkPrerequisites() which is guarded -- an unexpected `prlctl
  list --json` shape threw uncaught instead of failing gracefully.
- copyArtifactsBack() hardcoded the literal Windows target triple instead
  of using the file's own TARGET constant that buildRemoteScript() already
  uses everywhere else.
- `prlctl stop`'s exit code was discarded via bare `.nothrow()` -- a failed
  stop (wedged VM) printed the same message as a successful one. Now checks
  and reports the exit code.
- `prlctl start` ran before the try/finally responsible for stopping the
  VM, so a start that rejects after the VM has actually begun starting left
  nothing to run the cleanup. Moved inside the try.
- buildRemoteScript()'s `cd ${repoPath}` was unquoted in the single command
  line sent to the remote shell -- a repo path containing a space (a real
  shape for an operator-configurable REPO_PATH) would word-split and break
  the very first step of the remote build. Quoted.

Also dropped an unused, misleadingly-named `crate` field from
build-windows-quick.ts's SIDECAR_BINARIES (nodespaced/nodespace are binary
names, not the cargo package names the field's values would suggest to a
future maintainer wiring it into a `-p` flag by analogy with the sibling
build-sidecar-binaries.ts, which does use `crate` for that).

Closes #2634

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@mstomar125
mstomar125 merged commit a8bf32c into main Sep 15, 2026
@mstomar125
mstomar125 deleted the issue-1438-followup-review-gaps branch September 15, 2026 12:22
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.

build-windows.ts (Tier 2): fix correctness/robustness gaps found by post-merge review

1 participant