Repository navigation
Fix correctness/robustness gaps in build-windows.ts found by post-merge review - #2635
Merged
Merged
Conversation
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A
code-reviewpass 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:isVmRunning()swallowedprlctlfailures silently — a failedprlctl 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.prlctl startwas outside thetry/finally— if starting the VM itself threw, thefinallyblock'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 insidetry.buildRemoteScript'scdwas unquoted — the whole script is joined into a single remote shell command line with no further escaping; aREPO_PATHcontaining a space (a real shape —NODESPACE_WIN_VM_REPO_PATHis operator-configurable, and Git-Bash-style Windows paths like/c/Users/Build Machine/nodespace-coreare exactly this) would word-split and fail the build at its very first step. Nowcd '${repoPath}'.copyArtifactsBack()had two compounding scp bugs: the.msisource had nouser@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 defaultREPO_PATH(~/nodespace-core) silently spliced this Mac's own home directory into what must stay a purely remote path. Fixed by extractingbuildScpSources(), which builds the completeuser@host:pathstrings in plain JS before they ever reach the$template.envOrDefaultused??instead of checking for empty string —process.env.X ?? fallbackonly catchesnull/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. ExtractedenvOrDefault()with an explicit empty-string check and covered it with tests.SIDECAR_BINARIESinbuild-windows-quick.tsfrom{crate, bin}pairs to a plainstring[]— thecratefield 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
scripts/build-windows.test.tsforenvOrDefault(unset / empty-string / real-value),buildRemoteScriptquoting (space-in-path case), andbuildScpSources(prefix presence, tilde-safety, distinct nsis/msi targets)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 "*")🤖 Generated with Claude Code