Skip to content

fix: run implementation delegates through tinyexec on Windows - #139

Merged
petebacondarwin merged 10 commits into
mainfrom
investigate/issue-19
Oct 5, 2026
Merged

petebacondarwin merged 10 commits into
mainfrom
investigate/issue-19

Conversation

@penalosa

@penalosa penalosa commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Windows cannot directly execute Wrangler and Vite's Node-shebang delegate entrypoints, causing cf dev, cf build, and build-backed deploy commands to fail with spawn EFTYPE. Launch delegates with tinyexec 1.3.1, including its fix for extensionless Windows entrypoints.

  • Replace Execa in both implementation delegation and detected framework commands, remove its dependencies, and update the compiled Wrangler test bundle and process mock.
  • Preserve argument boundaries, PATH and environment inheritance, output routing, exit codes, and signal reporting. Keep the framework command's five-second SIGTERM fallback and avoid relaying Windows Ctrl+C twice.
  • Run the CLI suite on Linux, macOS, and Windows, and add regression coverage for PATH inheritance, command failures, signal exits, and listener cleanup.
  • Exercise actual Windows console Ctrl+C in an isolated console for extensionless and .cmd delegates across all output modes. Check delayed graceful cleanup, parent exit, signal listener restoration, and no surviving processes. Retain tinyexec's windowsHide default; inherited stdin and stderr preserve the existing console.

Fixes #19.

Validation

  • Focused delegate, framework, build, process-controller, and dotenv tests: 116 passed across 5 files.
  • Additional focused delegate/framework run: 50 passed; 6 Windows-only console cases skipped on macOS.
  • Windows console Ctrl+C tests: all 6 passed in Windows CI.
  • pnpm check from the repository root: passed.
  • Wrangler compatibility suite: 637 passed across 58 files; existing skipped/todo tests remain.

Cross-platform CI passed on Linux, macOS, and Windows, including the repository checks and Wrangler compatibility suite: https://github.com/cloudflare/cf/actions/runs/37312038459.

@pkg-pr-new

pkg-pr-new Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/cf@139

commit: c4d3276

@ask-bonk

ask-bonk Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

cf --help startup

mean stddev min max
PR 334.9 ms 4.5 ms 327.3 ms 343.4 ms
base 335.8 ms 10.1 ms 326.5 ms 369.1 ms

Δ (PR vs base): — -0.9 ms (-0.3%)

Measured with hyperfine on ubuntu-latest (3 warmup runs, 20 timed runs). CI numbers carry ±a few ms of runner jitter; treat small deltas as noise.

@neotan

neotan commented Oct 4, 2026

Copy link
Copy Markdown

I ran this PR's prerelease build (pkg.pr.new/cf@139, built from a10f467) on Windows 11 with Node 24.19 and PowerShell 5.1.

Both delegates start now. A plain Wrangler project builds, dry-run deploys, and serves with cf dev, and --mode "a b&c" passes through. To reach cf-vite I used a cf init project with vite removed from its direct dependencies, because otherwise cf detects Vite and runs npx vite itself. That project builds, dry-run deploys, and serves too. With cf 1.0.0-beta.12 the same two projects fail with spawn EFTYPE and spawn ...\cf-vite ENOENT.

Two things about the new Windows CI job. The run on a10f467 failed at checkout with "Filename too long" on a generated SDK path, and the workflow at a022326 still checks out without long paths enabled. Running the full CLI suite locally at a022326 gives 14 failures in 8 files, and all 8 files fail the same way on main, mostly tests that expect forward slashes in paths.

When the delegate itself fails (a syntax error in the Worker), cf exits with -1073740791 after Node prints Assertion failed: !(handle->flags & UV_HANDLE_CLOSING), file src\win\async.c, line 94, instead of exiting 1. Published beta.12 crashes the same way after its spawn error, so this doesn't come from the PR, but on Windows scripts won't get the delegate's exit code. I haven't looked into the cause.

@petebacondarwin

Copy link
Copy Markdown
Collaborator

We just removed execa from Wrangler!

cloudflare/workers-sdk#12369

@ask-bonk

ask-bonk Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

The new Windows matrix job cannot exercise this change: CI run 37300734837 fails in Checkout with Filename too long for a generated SDK path, so install and the CLI suite are skipped. Enable Git long-path support before actions/checkout runs.

    runs-on: ${{ matrix.os }}
    timeout-minutes: 15
    steps:
      - name: Enable long paths on Windows
        if: runner.os == 'Windows'
        shell: pwsh
        run: git config --system core.longpaths true

      - name: Checkout
        uses: actions/checkout@v6
        with:
          fetch-depth: 1
          persist-credentials: false

@ask-bonk

ask-bonk Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

🤖 I've done a thorough review of your PR.

Adds Execa-based delegate spawning and cross-platform CI coverage.

  1. High: Windows CI fails during checkout on an overlong generated SDK path, so the new Windows suite never runs. Posted a suggested workflow fix: fix: run implementation delegates through tinyexec on Windows #139 (comment)

github run

@ask-bonk

ask-bonk Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Review: 1 findings.

🤖 I've done a thorough review of your PR.

Adds Execa-based implementation delegation and cross-platform CLI CI coverage.

  1. High packages/cli/src/commands/dev/spawn.ts:125: Execa defaults windowsHide to true, preventing delegates from receiving Ctrl+C. Since Windows SIGINT is intentionally not relayed, cf dev can remain waiting while its delegate continues running. Set windowsHide: false for this inherited-stdio subprocess.

github run

@ask-bonk

ask-bonk Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

No new concerns since the last review

github run

@ask-bonk

ask-bonk Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

No new concerns since the last review

github run

@petebacondarwin petebacondarwin changed the title fix: run implementation delegates through Execa on Windows fix: run implementation delegates through tinyexec on Windows Oct 5, 2026

@ask-bonk ask-bonk Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows process review: tinyexec still hides both child consoles, so the intentional no-relay SIGINT handling leaves cf dev/framework delegates running after Ctrl+C.

Comment thread packages/cli/src/commands/dev/spawn.ts Resolved
Comment thread packages/cli/src/lib/autoconfig.ts Resolved
@ask-bonk

ask-bonk Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

🤖 I've done a thorough review of your PR.

Replaces Execa delegate launching with tinyexec and adds Windows CI/test coverage.

  1. High: tinyexec defaults to windowsHide: true; both Windows launch paths intentionally do not relay Ctrl+C, so delegates may remain running. Posted suggestions on spawn.ts and autoconfig.ts to set windowsHide: false.

github run

@petebacondarwin
petebacondarwin marked this pull request as ready for review October 5, 2026 12:14
@petebacondarwin
petebacondarwin requested a review from a team as a code owner October 5, 2026 12:14
@ask-bonk

ask-bonk Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@ask-bonk

ask-bonk Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@petebacondarwin
petebacondarwin added this pull request to the merge queue Oct 5, 2026
Merged via the queue into main with commit a02886b Oct 5, 2026
13 checks passed
@petebacondarwin
petebacondarwin deleted the investigate/issue-19 branch October 5, 2026 13:27
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.

Windows: cf build / dev / deploy fail with spawn EFTYPE when delegating to Wrangler

3 participants