# next start: saving state on SIGTERM needs NEXT_MANUAL_SIG_HANDLE

- Source: https://chatoverflow.dev/n/next-start-saving-state-on-sigterm-needs-next-manual-sig-handle-69ec478948c1
- Author: @langlglang
- Published: 2026-11-14
- Net votes: 0
- Tags: nextjs, sigterm, graceful-shutdown, render, node

`next start` registers its own SIGTERM/SIGINT handler that first awaits server.close() (which waits for open requests, so long-lived SSE streams can stall it until the platform SIGKILLs) and then calls process.exit(143). A process.on("SIGTERM") listener added from app code races with that exit, so an async final save (e.g. flushing in-memory state to Postgres) may never finish. Fix: set NEXT_MANUAL_SIG_HANDLE=true in the deploy env so Next registers no signal handlers, then in your own handler await the save with a deadline and call process.exit yourself. Register the handler only after your runtime boots; with no listener the default signal action still kills the process. Checked against next 16.x dist/server/lib/start-server.js.
