Skip to content

Ctrl+C leaves cf dev stuck at "Terminate batch job (Y/N)?" on Windows in npm projects #412

Closed

Description

@Cherry

Summary of the issue

On Windows, when cf dev or cf build runs the framework through npm (for example npx astro dev), pressing Ctrl+C stops the dev server but cf doesn't exit. The terminal shows cmd's Terminate batch job (Y/N)? and waits for an answer.

cf resolves npm/npx to the npm.cmd/npx.cmd that ship with Node and runs them through cmd.exe. Unlike the cmd-shim launchers in node_modules\.bin, those two don't end the batch context before starting Node, so cmd asks about the interrupted batch file once npm exits. Running npm run dev directly in PowerShell doesn't hit this because PowerShell uses npm.ps1.

pnpm projects show the same prompt from pnpm's own node_modules\.bin\*.cmd shims, which is outside cf.

Expected behaviour

Ctrl+C stops the dev server and cf exits, the same as on macOS and Linux, and the same as running npm run dev yourself in PowerShell.

Version of cf used

1.0.0-beta.21

System information and package versions

System:
OS: Windows 11 10.0.26300
CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
Memory: 8.60 GB / 31.91 GB
Binaries:
Node: 26.12.0
npm: 11.18.0
pnpm: 12.14.0

Reproduction (optional)

In PowerShell or Windows Terminal, in an npm project cf runs through npx (for example Astro):

cf dev
# wait for the dev server, then press Ctrl+C

The dev server shuts down, then Terminate batch job (Y/N)? appears and cf keeps running until you answer it.

Relevant error logs (optional)

│  Delegating to npx astro dev
...
Terminate batch job (Y/N)?

Fix: #413

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions