Skip to content

fix(npm-script): make Windows android dev spawns reliable#2156

Open
UnschooledGamer wants to merge 5 commits into
Acode-Foundation:mainfrom
UnschooledGamer:fix/windows-spawn-einval
Open

fix(npm-script): make Windows android dev spawns reliable#2156
UnschooledGamer wants to merge 5 commits into
Acode-Foundation:mainfrom
UnschooledGamer:fix/windows-spawn-einval

Conversation

@UnschooledGamer
Copy link
Copy Markdown
Member

@UnschooledGamer UnschooledGamer commented Jun 5, 2026

Summary:

  • run rspack watch via local @rspack/cli entrypoint with Node
  • run Cordova commands via local Cordova CLI entrypoint with Node when available\n- keep environment sanitization for spawned processes

Why:

Windows command shim spawning (npx/cordova.cmd) was causing spawn EINVAL/ENOENT during dev startup. Direct Node CLI entrypoints make process execution reliable across shells.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 5, 2026

Greptile Summary

This PR replaces Windows-fragile command-shim spawns (npx, cordova.cmd) with direct Node + local CLI entrypoint invocations to eliminate EINVAL/ENOENT errors during dev startup on Windows. It also adds environment sanitisation via buildSpawnEnv and a process.exit(1) on rspack startup failure.

  • Adds CORDOVA_BIN / local rspack path constants and fs.existsSync guards that fall back to system commands when local bins are absent.
  • Introduces resolveSpawnCommand (Windows .cmd suffix appender) and buildSpawnEnv (strips invalid =-prefixed env keys) as shared helpers across all spawn sites.
  • Escalates rspack watcher errors from a logged warning to a process.exit(1), making silent dev-session failures visible.

Confidence Score: 5/5

Safe to merge — the change is scoped to the dev orchestration script and directly targets a real Windows compatibility gap with a well-understood fix.

The primary fix (using local Node+script entrypoints for rspack and Cordova) is correct and addresses the root cause of the Windows spawn failures. The previously flagged issues are resolved. Remaining concerns are limited to fallback code paths that only trigger when local bins are absent.

utils/scripts/dev.js — the Windows .cmd fallback branches in startRspackWatch and launchApp could still emit EINVAL in non-standard shell environments, but this only matters when local bins are absent.

Important Files Changed

Filename Overview
utils/scripts/dev.js Core dev orchestrator updated with Windows-reliable spawn helpers; previously flagged issues (rspack existence guard, indentation) are resolved; fallback .cmd spawns lack shell: true which can still trigger EINVAL on some Windows shell configurations.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Dev script starts] --> B[startRspackWatch]
    B --> C{local rspackBin exists?}
    C -- yes --> D[spawn node rspackBin]
    C -- no --> E[warn: fallback to npx]
    E --> F[spawn npx.cmd on Windows]
    D --> G[rspack compiles]
    F --> G
    G --> H{error event?}
    H -- yes --> I[log warn + process.exit 1]
    H -- no --> J{stdout has compiled?}
    J -- yes --> K[onCompiled callback]
    K --> L{appLaunched?}
    L -- no --> M[launchApp after 3s]
    L -- yes --> N[broadcast reload]
    M --> O{local CORDOVA_BIN exists?}
    O -- yes --> P[spawn node CORDOVA_BIN args]
    O -- no --> Q[spawn cordova.cmd args]
    P --> R[Cordova run]
    Q --> R
Loading

Reviews (2): Last reviewed commit: "chore: revert & fmt greptile suggestion" | Re-trigger Greptile

Comment thread utils/scripts/dev.js
Comment thread utils/scripts/dev.js
@UnschooledGamer UnschooledGamer changed the title fix(dev): stabilize Windows dev process spawns fix(npm-script): make Windows dev spawns reliable in android dev Jun 5, 2026
UnschooledGamer and others added 3 commits June 5, 2026 22:00
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@UnschooledGamer
Copy link
Copy Markdown
Member Author

@greptile_apps review again

@UnschooledGamer UnschooledGamer changed the title fix(npm-script): make Windows dev spawns reliable in android dev fix(npm-script): make Windows android dev spawns reliable Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant