CLI: Fix Ctrl+C termination on Windows after npm create storybook@latest#33960
CLI: Fix Ctrl+C termination on Windows after npm create storybook@latest#33960Copilot wants to merge 3 commits into
npm create storybook@latest#33960Conversation
…book dev after init Co-authored-by: valentinpalkovic <5889929+valentinpalkovic@users.noreply.github.com>
npm create storybook@latest
|
|
@copilot The |
|
… Ctrl+C Co-authored-by: valentinpalkovic <5889929+valentinpalkovic@users.noreply.github.com>
... Good catch — that's the real root cause. Fixed in 415398c.
The fix explicitly calls
Addressed in 415398c. Added |
npm create storybook@latestnpm create storybook@latest
|
View your CI Pipeline Execution ↗ for commit 415398c
☁️ Nx Cloud last updated this comment at |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughModified the Storybook dev initialization process to handle clean process termination across platforms. Added Windows-specific subprocess tree cleanup using taskkill and signal handlers, along with stdin raw-mode reset for Windows TTY environments. These changes ensure reliable Ctrl+C behavior and proper process cleanup. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
✨ Finishing Touches
Comment |
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 185 | 185 | 0 |
| Self size | 76 KB | 76 KB | 0 B |
| Dependency size | 32.19 MB | 32.17 MB | 🎉 -19 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/angular
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 185 | 185 | 0 |
| Self size | 139 KB | 139 KB | 0 B |
| Dependency size | 30.40 MB | 30.38 MB | 🎉 -19 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/ember
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 189 | 189 | 0 |
| Self size | 15 KB | 15 KB | 🚨 +18 B 🚨 |
| Dependency size | 28.90 MB | 28.88 MB | 🎉 -19 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 534 | 534 | 0 |
| Self size | 648 KB | 648 KB | 🎉 -120 B 🎉 |
| Dependency size | 59.86 MB | 59.84 MB | 🎉 -19 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 92 | 92 | 0 |
| Self size | 1.12 MB | 1.12 MB | 0 B |
| Dependency size | 22.47 MB | 22.45 MB | 🎉 -19 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-native-web-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 124 | 124 | 0 |
| Self size | 30 KB | 30 KB | 0 B |
| Dependency size | 23.76 MB | 23.74 MB | 🎉 -19 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 82 | 82 | 0 |
| Self size | 35 KB | 35 KB | 0 B |
| Dependency size | 20.25 MB | 20.24 MB | 🎉 -19 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 271 | 271 | 0 |
| Self size | 24 KB | 24 KB | 🚨 +12 B 🚨 |
| Dependency size | 44.53 MB | 44.51 MB | 🎉 -19 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/server-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 197 | 197 | 0 |
| Self size | 16 KB | 16 KB | 🎉 -12 B 🎉 |
| Dependency size | 33.44 MB | 33.42 MB | 🎉 -19 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 183 | 183 | 0 |
| Self size | 779 KB | 779 KB | 0 B |
| Dependency size | 67.35 MB | 67.32 MB | 🎉 -27 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 176 | 176 | 0 |
| Self size | 32 KB | 32 KB | 0 B |
| Dependency size | 65.87 MB | 65.85 MB | 🎉 -28 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/preset-react-webpack
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 167 | 167 | 0 |
| Self size | 18 KB | 18 KB | 0 B |
| Dependency size | 31.40 MB | 31.38 MB | 🎉 -19 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/react
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 58 | 58 | 0 |
| Self size | 1.19 MB | 1.19 MB | 🚨 +6 B 🚨 |
| Dependency size | 13.21 MB | 13.19 MB | 🎉 -19 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
|
I am closing this since we are waiting for a proper resolution of bombshell-dev/clack#408 |
On Windows, after
npm create storybook@latestcompletes and auto-starts the dev server, Ctrl+C has no effect — the only escape is closing the terminal.Root Cause
The root cause is a known issue in
@clack/core(bombshell-dev/clack#408): theblock()function (used internally by spinners during dependency installation) setsstdin.setRawMode(true)on all platforms, but intentionally skipssetRawMode(false)cleanup on Windows (!isWindows && setRawMode(false)). After init completes, stdin remains in raw mode, causing Ctrl+C to emit\x03as a character instead of triggeringSIGINT— so no signal handler ever fires.Changes
doInitiate()completes on Windows, explicitly callsprocess.stdin.setRawMode(false)(when stdin is a TTY and still in raw mode) to work around the clack bug and ensure Ctrl+C correctly triggersSIGINT.runStorybookDev(defense-in-depth): RegisterSIGINT/SIGTERMhandlers before awaiting the subprocess. On signal:spawnSync('taskkill', ['/T', '/F', '/PID', <pid>])— forcefully kills the entire process tree, bypassing any residual cmd.exe batch-job prompt interceptionsubprocess.kill()— standard kill, sufficient since Unix process groups already propagate signalsprocess.exit(0)— ensures the parent exits cleanly in both casesprocess.offin afinallyblock removes handlers if the subprocess exits normallyprocess.on('SIGINT', ...)placeholderNo new dependencies —
spawnSyncis a Node.js built-in.taskkill /T /Fis available on all Windows versions.Original prompt
npm create storybook@latestin Windows, the program cannot be terminated using Ctrl+C #33959🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.
Summary by CodeRabbit