Skip to content

feat: support force close with double Control+C#163

Merged
pi0 merged 1 commit intomainfrom
feat/force-close
Jan 17, 2026
Merged

feat: support force close with double Control+C#163
pi0 merged 1 commit intomainfrom
feat/force-close

Conversation

@pi0
Copy link
Member

@pi0 pi0 commented Jan 17, 2026

Graceful shutdown takes ~3sec while sometimes it is unnecessary to wait, this improves UX by allowing second Control+C (or shutdown signal) to immediately force close server:

^C
Shutting down server in 3s... (press Ctrl+C again to force close)^C <-- second time
Force closing...
``

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Bug Fixes**
  * Improved server graceful shutdown behavior with enhanced force-close operation handling.
  * Added ability to force-close the server during shutdown using Ctrl+C keyboard shortcut.
  * Enhanced shutdown messages to provide clearer instructions about forcing server closure when necessary.

<sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub>

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Enhanced graceful shutdown mechanism in src/_plugins.ts by introducing a force-close callback variable. Implemented re-entrant shutdown handling and force-close timeout logic. Improved user messaging to include Ctrl+C force-close instruction. Changes enable immediate shutdown on subsequent invocations.

Changes

Cohort / File(s) Summary
Graceful Shutdown Force-Close Logic
src/_plugins.ts
Added forceClose callback variable to manage immediate force-close path. Implemented re-entrant shutdown handling that invokes forceClose on subsequent shutdown calls. Enhanced shutdown start message with Ctrl+C instruction. Added force-close implementation that clears timeout, logs progress, calls server.close(true), and resolves promise. Configured force-close to trigger after graceful shutdown timeout expires.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A hop through the shutdown, so graceful and grand,
With force-close awaiting, we've got it all planned,
Press Ctrl+C swift, if you cannot wait long,
The rabbits say "close!" and the server goes strong!
No more hanging 'round—just clean exits, my friend,
A powerful finale... The End. 🎬

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 17, 2026

Open in StackBlitz

npm i https://pkg.pr.new/h3js/srvx@163

commit: 0894e25

@pi0 pi0 merged commit 7f593b7 into main Jan 17, 2026
12 of 13 checks passed
@pi0 pi0 deleted the feat/force-close branch January 17, 2026 20:05
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.

1 participant

Comments