Skip to content

fix(core): handle graceful shutdown when server fails to start#3281

Merged
PierreBrisorgueil merged 3 commits into
masterfrom
fix/graceful-shutdown
Mar 19, 2026
Merged

fix(core): handle graceful shutdown when server fails to start#3281
PierreBrisorgueil merged 3 commits into
masterfrom
fix/graceful-shutdown

Conversation

@PierreBrisorgueil

Copy link
Copy Markdown
Contributor

Summary

  • Fix shutdown() hanging when app.start() rejects — server.then() on a rejected promise never executes, so process.exit() is never called
  • Replace .then() with await + catch to handle rejected server promise and exit immediately
  • Add 5s force-exit timeout as safety net against any future shutdown hang

Closes #3278

Copilot AI review requested due to automatic review settings March 19, 2026 09:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a shutdown hang in core startup failure scenarios by ensuring shutdown() handles a rejected app.start() promise and by adding a safety force-exit timeout.

Changes:

  • Replace server.then(...) with await server to ensure shutdown logic runs even when server is a rejected Promise.
  • Add a 5s force-exit timeout to avoid indefinite hangs during graceful shutdown.

Comment thread lib/app.js Outdated
Comment thread lib/app.js Outdated
Comment thread lib/app.js Outdated
@coderabbitai

coderabbitai Bot commented Mar 19, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@PierreBrisorgueil has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 25 minutes and 32 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e5283492-de3a-441f-a956-e49910908050

📥 Commits

Reviewing files that changed from the base of the PR and between 6df1249 and 0ec2800.

📒 Files selected for processing (3)
  • lib/app.js
  • modules/billing/README.md
  • modules/billing/config/billing.development.config.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/graceful-shutdown
📝 Coding Plan
  • Generate coding plan for human review comments

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.

- Extract hard-coded timeout into FORCE_SHUTDOWN_TIMEOUT_MS constant
- Add JSDoc for shutdown function with @param and @returns
- Log error in catch block instead of swallowing silently
@PierreBrisorgueil
PierreBrisorgueil merged commit 4b0938c into master Mar 19, 2026
3 checks passed
@PierreBrisorgueil
PierreBrisorgueil deleted the fix/graceful-shutdown branch March 19, 2026 09:22
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.

fix(core): graceful shutdown hangs when server fails to start

2 participants