‹ Back to Blog

Graceful Shutdown Is Having A Moment

Engineering

Every deploy is a quiet race. When a server gets SIGTERM, any request still in flight has to finish or get dropped, and for a long time most frameworks’ answer to ‘what if a client never lets go?’ was to wait forever. Three recent changes, across Puma on the Ruby side and NestJS on the Node.js side, are finally putting bounds on that window, and they change what you should expect to see around a restart.

Puma bounds the request-read phase (shipped)

Puma 8.0.3 added a shutdown_body_timeout option (default 25 seconds) as part of its security release. It closes a specific hole: a client that trickles a request body one byte at a time could otherwise hold a graceful shutdown open indefinitely. Now the phase where Puma is still reading an incomplete request is bounded. This one is shipped and worth upgrading for on its own merits; there is more on the full advisory set in our Ruby Security Week post.

The phase Puma hasn’t bounded yet (proposed)

shutdown_body_timeout only covers reading the request. The other phase, where your app is still streaming a response to a client that keeps reading (SSE, long-poll, ActionController::Live), is still unbounded in single mode. An open proposal, Puma #4119, would change force_shutdown_after from its wait-forever default of -1 to a finite 30 seconds, matching worker_shutdown_timeout.

It is a breaking change worth flagging early: a long-running request still going when the timer expires would be terminated. Teams that depend on the current behavior could opt back in with force_shutdown_after :forever. In cluster mode this gap is already covered, since the master process SIGKILLs a worker after worker_shutdown_timeout, but single-mode deployments have no backstop today. This one is still a proposal, not merged, so treat it as a direction rather than a date.

NestJS brings it to the microservice transports (merged, not yet released)

On the Node.js side, NestJS merged a four-PR series adding graceful shutdown to its microservice transports: Redis, NATS, MQTT, TCP, and RabbitMQ. It is opt-in. Set gracefulShutdown and a gracePeriod (10 seconds by default), and close() stops accepting connections, closes idle ones, and waits for in-flight handlers via waitForHandlersInFlight before tearing anything down. For RabbitMQ specifically, that fixes lost replies with noAck: true and duplicate work with noAck: false.

Note the status: these are landed in main but not in a tagged NestJS release yet, so you cannot install your way to them today. Default behavior is unchanged, so the series is not breaking when it does ship.

What this means at deploy time

The common thread across all three is the same narrow window between SIGTERM and process exit, where requests get dropped, replies get lost, and background jobs get duplicated. Those are exactly the failures that spike right after a deploy and are nearly impossible to reproduce locally. At Scout, we trace request duration and errors continuously, so watching your error rate and endpoint timings around each deploy is the fastest way to tell whether a streaming endpoint is holding shutdown open or a restart is quietly dropping in-flight work. Get started with Scout for free and keep an eye on your next few deploys.

For application monitoring with errors, logs, and traces, Scout Monitoring provides the fastest insights without the bloat.