Skip to content

fix(core): unblock Windows deploy, resolve npx/npm spawn - #28

Merged
pranavosu merged 15 commits into
mainfrom
ci/win
Jun 18, 2026
Merged

fix(core): unblock Windows deploy, resolve npx/npm spawn#28
pranavosu merged 15 commits into
mainfrom
ci/win

Conversation

@pranavosu

@pranavosu pranavosu commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #19 - npm run deploy (and sandbox, sandbox:destroy, destroy, and external-DB migrations) crashed on Windows with spawnSync npx ENOENT.

Root cause: on Windows npm/npx/cdk/tsx are .cmd shims. The deploy lifecycle spawned them with execFileSync/spawn, which do a direct exec without Windows PATHEXT resolution (so npx is never found), and which Node refuses to run for .cmd/.bat without a shell. The crash happens at the spawn step, before any AWS call.

Fix: a small cross-spawn-backed helper (runSync/spawnCommand) that resolves the shim and quotes arguments correctly (including project paths with spaces), keeping the safe array-arg form (no shell injection). All six npm/npx/cdk spawn sites in deploy.ts, destroy.ts, sandbox.ts, and external-migrations-step.ts now route through it. node invocations are unchanged (node.exe resolves fine).

Verification

  • @aws-blocks/core builds clean; all 549 core unit tests pass.
  • Helper smoke-tested: success returns, non-zero exit throws, missing binary throws ENOENT, spawnCommand returns a live ChildProcess.
  • TEMP windows-latest CI job (.github/workflows/windows-deploy-check.yml) reproduces the original ENOENT and asserts the helper spawns the npx/npm shims on Windows. Delete this workflow before merge - it only triggers on ci/win/dispatch and should not land on main.

Release

Includes a changeset (@aws-blocks/core patch) so this ships as a patch release to unblock users.

Not covered (separate Windows gaps, not part of #19)

  • console.ts spawns open (macOS-only) and aws.
  • cleanup.ts uses lsof/kill (Unix-only).

Worth a follow-up if full Windows support is a goal.

…/destroy lifecycle spawned npm/npx/cdk/tsx via execFileSync/spawn. On Windows these are .cmd shims, so a direct exec fails with 'spawnSync npx ENOENT' (no PATHEXT resolution), and Node refuses to run .cmd/.bat without a shell. Route these calls through a cross-spawn-backed runSync/spawnCommand helper that resolves the shim and quotes args (incl. paths with spaces) while keeping the safe array-arg form. Fixes #19
…dows fix without AWS: reproduces the raw execFileSync('npx') ENOENT, then asserts the runSync/spawnCommand helper spawns the npx/npm shims on windows-latest. Triggered on the ci/win branch and via workflow_dispatch. Delete this workflow once #19 is verified/merged.
@pranavosu
pranavosu requested a review from a team as a code owner June 17, 2026 20:18
@pranavosu pranavosu changed the title fix core windows spawn 19 fix(core): unblock Windows deploy, resolve npx/npm spawn ENOENT #19 Jun 17, 2026
@pranavosu pranavosu changed the title fix(core): unblock Windows deploy, resolve npx/npm spawn ENOENT #19 fix(core): unblock Windows deploy, resolve npx/npm spawn Jun 17, 2026
…the default template from a local registry built off this branch, then runs 'npm run build' and a 'npm run dev' smoke (waits for the Blocks server on :3000, then tears down). Confirms a Windows user can build and run a Blocks app end to end with no AWS. Validated locally on macOS before pushing. Temporary — delete with the rest of windows-deploy-check.yml before merge.
svidgen
svidgen previously approved these changes Jun 17, 2026
…ld:packages lists workspaces non-topologically, so on a clean checkout a referenced package's generated version.ts is missing when a dependent compiles (tsc TS2307 on './version.js'). Generate all version files via the workspace prebuild step first.
…os.tmpdir() on Windows runners is the mangled short path (C:\Users\RUNNER~1\...). Vite's html-inline-proxy fails when the short/long path forms differ ('No matching HTML proxy module found'). Use RUNNER_TEMP (D:\a\_temp, a clean long path) so 'npm run build' mirrors a real user's project dir.
…op the temporary spawn-check and template build/dev smoke jobs (and their driver script). Add windows-e2e.yml: a standalone workflow that runs the real production E2E on windows-latest, mirroring the Linux e2e-production job (OIDC creds, real cdk deploy/destroy). This is the high-fidelity #19 regression check — it runs the actual 'npm run deploy' spawn path on Windows. Kept separate from pr-checks.yml and not wired into the required gate, so it is optional for now (runs on every PR, non-blocking). Uses a windows-scoped stack suffix and an always-run destroy backstop.
… CDK constructs and the pipeline stage loader imported the backend by raw absolute path with a cache-busting query (${absPath}?stack=...). On Windows an absolute path like D:\... is parsed as URL scheme 'd:' and rejected with ERR_UNSUPPORTED_ESM_URL_SCHEME during synth. Build a file:// URL via pathToFileURL first. Also fix the Windows E2E workflow to set BLOCKS_TEST_ENV via step env (the test:production npm script uses a bash-only VAR=value prefix that cmd.exe can't parse) and expand the changeset to cover both Windows deploy fixes.
…geset - Scaffold create-blocks-app --template backend (Lambda + API Gateway only, no DynamoDB/GSI/Aurora) for fast deploy/destroy; drop the build phase (backend template has no frontend). Phases: dev -> sandbox -> deploy. - Add a no-op patch changeset to republish bb-app-setting, bb-auth-cognito, bb-auth-oidc, bb-distributed-table, bb-email-client, bb-knowledge-base, bb-kv-store, bb-tracer.
…ings Replace log-string matching with product-artifact signals: - dev: wait until .blocks-sandbox/config.json is written and its apiUrl port answers HTTP (port-agnostic; fixes the :3001 hardcoded-3000 miss). - sandbox: wait until CDK writes .blocks-sandbox/outputs.json. Both fail fast if the child exits early or times out. No console-log wording dependency.
…- windows-e2e: schedule (08:00 & 14:00 UTC) + workflow_dispatch, drop PR trigger; per-run stack suffix; condense comments. - Trim the changeset and verbose code comments to the essentials. - Revert the e2e.test.ts npx->node change (unused after switching to the scaffolded backend-template driver). cross-spawn stays a runtime dependency (it executes in the user's project).
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.

Deployment failing in Windows

2 participants