# SC201: In-flight request was interrupted

> SC201 (in-flight request was interrupted) means a request running at SIGTERM was cut off before its response ended. Stop exiting or closing sockets early.

Source: https://shutdown.jscrate.dev/docs/codes/sc201
Last updated: 2026-09-23

`SC201` means an active request lost its connection after `SIGTERM`. Users
often see the same failure as a reset connection or a `502` during deployment.

| | |
| --- | --- |
| Code | `SC201` (FAIL) |
| Stage | In-flight responses |
| CLI exit code | 1 |
| What it means | A request that was running when SIGTERM arrived was cut off: the connection was reset or closed before the response ended. |
| Message | `In-flight request was interrupted: <error>` |
| First thing to check | Do not call `process.exit()`, `closeAllConnections()` or destroy sockets while requests are still being answered. |

## What usually cuts the request off?

- There is no `SIGTERM` handler, so Node.js exits immediately.
- The handler calls `process.exit()` before requests finish.
- Code destroys all sockets, including active ones.
- A wrapper process dies and takes the server with it.
- A second signal forces an early exit.

## How do I fix it?

Use `server.close()` to stop new connections and wait for its callback before
finishing cleanup. Do not destroy active sockets.

```js
process.on("SIGTERM", () => {
  server.close((error) => {
    if (error) process.exitCode = 1;
  });
});
```

If you track idle keep-alive connections, close only the idle connections.
Active responses must be allowed to end normally.

## How do I verify the fix?

The request should now end with `HTTP <status>` instead of `aborted`,
`ECONNRESET`, or another socket error. The process must exit only after the
request-finished event.

Run the test with `repeatSignalAfterMs` when operators or process managers may
send a second signal. This catches an early-exit branch that a single signal
does not reach.

## Related

- [Graceful shutdown in Node.js](https://shutdown.jscrate.dev/docs/guides/graceful-shutdown-nodejs)
- [SC200: Request did not finish](https://shutdown.jscrate.dev/docs/codes/sc200)
- [SC202: Wrong response status](https://shutdown.jscrate.dev/docs/codes/sc202)
- [Readiness and draining](https://shutdown.jscrate.dev/docs/guides/readiness-and-draining)
