Files
next.js/test/integration/cli
178a4c719f fix: use signal-based exit codes to prevent inspector blocking exit (#89351)
## What?

Use signal-based exit codes when shutting down the Next.js server to
prevent the process from waiting for the debugger to disconnect.

## Why?

When Node.js devtools are attached (via `--inspect` flag or the Next.js
DevTools "Attach debugger" feature), pressing Ctrl+C causes the dev
server to hang instead of exiting immediately. This happens because
calling `process.exit(0)` makes Node.js treat it as a normal exit, which
waits for all debuggers to disconnect before terminating.

In contrast, plain Node.js terminates immediately on SIGINT even with a
debugger attached, because signal-based termination doesn't wait for
debuggers.

## How?

Instead of calling `process.exit(0)` after cleanup, use signal-based
exit codes:

- SIGINT (signal 2) → `process.exit(130)` (128 + 2)
- SIGTERM (signal 15) → `process.exit(143)` (128 + 15)

This tells Node.js the process was terminated by a signal, which avoids
the debugger wait behavior.

Changes:
- Modified the cleanup function to accept the signal that triggered it
- Use `process.exit(signal === 'SIGINT' ? 130 : 143)` instead of
`process.exit(0)`
- Removed the previous `inspector.close()` workaround as it's no longer
needed

---------

Co-authored-by: Sebastian Sebbie Silbermann <[email protected]>
2026-02-04 12:07:41 +01:00
..