fix(core): handle graceful shutdown when server fails to start#3281
Conversation
There was a problem hiding this comment.
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(...)withawait serverto ensure shutdown logic runs even whenserveris a rejected Promise. - Add a 5s force-exit timeout to avoid indefinite hangs during graceful shutdown.
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
- 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
Summary
shutdown()hanging whenapp.start()rejects —server.then()on a rejected promise never executes, soprocess.exit()is never called.then()withawait+catchto handle rejected server promise and exit immediatelyCloses #3278