Graceful Shutdown in NestJS, for Spring Developers: Payment Killed

1 October 2026 nestjstypescriptnodejsjavaspring-bootkubernetes
PDF The design sheet The full architecture and the verified references. Free, no email.
Thumbnail for Graceful Shutdown in NestJS, for Spring Developers: Payment Killed 3:18
Watch on YouTube, or read on below.
Run this yourself → Clone the repo, docker compose up, and watch it happen

A deploy sends a stop signal to a NestJS service half a second into a three second payment. With Nest as created, the process was gone milliseconds later and the payment got a connection reset. Measured on 1 October 2026. Graceful shutdown has three separate jobs: stop advertising readiness, finish the work in flight, then exit. One shutdown hook is not the whole protocol.

Each stack as it comes

Spring Boot 4.1 with Actuator and nothing configured: server.shutdown is graceful and the health probes are on by default. The payment finished with 200, readiness answered 503 while new requests were still served, then connections were refused.

On Nest, enableShutdownHooks() finished the payment, but new requests were reset at once: no window for traffic to move.

The drain on Nest

A readiness check that reports 503 from beforeApplicationShutdown, and TerminusModule.forRoot({ gracefulShutdownTimeoutMs: 2000 }): the payment finished, readiness said 503 while new requests were still served, then connections were refused. The same shape as Spring.

The full code for every measurement is in the repository, and the free design sheet above has the checklist on one page.


Watch next

New videos land on Code with Sam - subscribe there if this was useful.

Get the interview pack

A free, practical pack for engineers preparing for senior backend interviews - the questions that actually get asked, and how to answer them like someone who has done the work.

New articles and videos when they land. No spam, and one click to leave.