Repository: vercel/next.js
File: packages/next/src/server/lib/start-server.ts (TypeScript)

Code before:
                if (telemetry) {
                  // Use flushDetached to avoid blocking process exit
                  // Each process writes to a unique file (_events_${pid}.json)
                  // to avoid race conditions with the parent process
                  telemetry.flushDetached('dev', dir)
                }
              } catch (_) {
                // Ignore telemetry errors during cleanup
              }
            }

            debug('start-server process cleanup finished')

            // Exit with signal-based exit code (128 + signal number) so that
            // Node.js treats this as a signal termination, not a normal exit.
            // This avoids waiting for the debugger to disconnect.
            // SIGINT = 2 -> 130, SIGTERM = 15 -> 143
            process.exit(signal === 'SIGINT' ? 130 : 143)
          })()
        }

        // Make sure commands gracefully respect termination signals (e.g. from Docker)
        // Allow the graceful termination to be manually configurable
        if (!process.env.NEXT_MANUAL_SIG_HANDLE) {
          process.on('SIGINT', () => cleanup('SIGINT'))
          process.on('SIGTERM', () => cleanup('SIGTERM'))
        }

        // Now load config via getRequestHandlers (single loadConfig call)
        const initResult = await getRequestHandlers({
          dir,
          port,
          isDev,
          onDevServerCleanup: cleanupListeners
            ? cleanupListeners.add.bind(cleanupListeners)
            : undefined,
          server,
          hostname,
          minimalMode,
          keepAliveTimeout,
          experimentalHttpsServer: !!selfSignedCertificate,
        })
        requestHandler = initResult.requestHandler
        upgradeHandler = initResult.upgradeHandler
        nextServer = initResult.server
        closeUpgraded = initResult.closeUpgraded

        // Log experimental features after config is loaded
        if (isDev) {
          logExperimentalInfo({
            experimentalFeatures: initResult.experimentalFeatures,

Review comment (suggestion):
The closure is not necessary according to [Node.js docs](https://nodejs.org/api/process.html#signal-events).
```suggestion
          process.on('SIGINT', cleanup)
          process.on('SIGTERM', cleanup)
```

Code after:
                if (telemetry) {
                  // Use flushDetached to avoid blocking process exit
                  // Each process writes to a unique file (_events_${pid}.json)
                  // to avoid race conditions with the parent process
                  telemetry.flushDetached('dev', dir)
                }
              } catch (_) {
                // Ignore telemetry errors during cleanup
              }
            }

            debug('start-server process cleanup finished')

            // Exit with signal-based exit code (128 + signal number) so that
            // Node.js treats this as a signal termination, not a normal exit.
            // This avoids waiting for the debugger to disconnect.
            switch (signal) {
              case 'SIGINT':
                process.exit(130)
                break
              case 'SIGTERM':
                process.exit(143)
                break
              default:
                // Make sure all handled signals have explicit exit codes.
                // This is just a fallback to guard against unsound types.
                signal satisfies never
                process.exit(128)
            }
          })()
        }

        // Make sure commands gracefully respect termination signals (e.g. from Docker)
        // Allow the graceful termination to be manually configurable
        if (!process.env.NEXT_MANUAL_SIG_HANDLE) {
          process.on('SIGINT', cleanup)
          process.on('SIGTERM', cleanup)
        }

        // Now load config via getRequestHandlers (single loadConfig call)
        const initResult = await getRequestHandlers({
          dir,
          port,
          isDev,
          onDevServerCleanup: cleanupListeners
            ? cleanupListeners.add.bind(cleanupListeners)
            : undefined,
          server,
          hostname,
          minimalMode,
          keepAliveTimeout,