Repository navigation
fix(node): exit when the server fails to listen - #5008
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
FindingsActionable comments posted: 2 Caution Review failedThe pull request is closed.
|
| Layer / File(s) | Summary |
|---|---|
Handle startup readiness failures src/presets/node/runtime/node-server.ts, src/presets/node/runtime/node-cluster.ts |
The Node server logs readiness errors and exits with status 1. The cluster runtime logs errors unless the worker is silent, then exits with status 1. |
Poll server URLs for readiness test/presets/_wait-for-server.ts, test/presets/_close-hook.ts, test/presets/node.test.ts |
The new helper polls a server URL, checks for child-process exit, and times out if the server does not respond. The close-hook and Node preset tests use it instead of port polling. |
Test listen failures test/presets/_listen-error.ts, test/presets/node.test.ts |
A new helper checks that a server started on an occupied port exits with status 1 and reports EADDRINUSE. Node server and cluster tests use the helper; the cluster test is skipped on Bun. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related PRs
- nitrojs/nitro#4724: Both PRs change the Node cluster runtime and overlap in the primary exit-code behavior and Node preset tests.
Suggested labels: v3
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
commit: |
srvx only sets process.exitCode on listen errors, so other handles (scheduled tasks, the cluster IPC channel) kept the process alive without serving. Also poll spawned test servers with fetch instead of binding the port. Resolves #5006
168bcfa to
d58e48b
Compare
Resolves #5006
When
node-servercan't listen (for exampleEADDRINUSE), srvx logs the error and setsprocess.exitCode = 1, but doesn't exit. Any other handle (the schedule runner's cron job, or the IPC channel in cluster workers) then keeps a process alive that serves nothing.The
node-serverandnode-clusterentries now observeserver.ready()and exit with code 1 when listening fails. In cluster mode every worker exits, so the primary exits with 1 too. Only non-silent workers log the error, so it isn't printed once per worker.Tests:
testListenErrorhelper. It holds a port and spawns the built output withoutTEST/CI, so the schedule runner starts. It expects exit code 1 andEADDRINUSEin the output. Runs fornode-serverandnode-cluster. Both tests failed before the fix (they hit the timeout).node.test.ts,bun.test.ts,deno-server.test.tsand_close-hook.tsare now polled withfetchinstead ofwaitForPort, which binds the port itself and could race the server'slisten(). The new helper also fails fast if the child exits.🤖 Generated with AI assistant