Repository navigation
Conversation
When the standalone server encounters an error during bind (such as EADDRINUSE), handle the server completion promise in server.ts rather than dropping it as an unhandled rejection, and ensure serve-app.ts logs and sets a non-zero exitCode for unhandled rejections outside a request context. Fixes withastro#18282 Co-Authored-By: Claude Code <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 6c82c7f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-Authored-By: Claude Code <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the port configured for
@astrojs/nodestandalone mode is already occupied, the built server process exits with code 0 without logging any error message (#18282).This happened because:
standalone()returns the server'sclosedpromise asdone, which rejects on the server'serrorevent.server.tsstarted the server but never handleddone, allowing the rejection to become unhandled.serve-app.tsregisters a process-levelunhandledRejectionlistener that silently returns whenrequestContext.getStore()is undefined (i.e. outside an active request). This swallowed the rejection at boot time. Because no socket remained listening, the event loop emptied and Node exited cleanly with code 0.Solution
packages/integrations/node/src/server.ts, catch errors onstartServer().done, log them, and exit with code 1.packages/integrations/node/src/serve-app.ts, log rejections occurring outside a request context and setprocess.exitCode = 1rather than silently ignoring them.packages/integrations/node/test/standalone-error.test.tsverifying that starting a standalone server when the port is occupied exits with code 1 and logs theEADDRINUSEerror.@astrojs/node.Fixes #18282
Testing
packages/integrations/node/test/standalone-error.test.tswith verified RED / GREEN mutation testing:packages/integrations/node(Prerendering, Redirects, Aborted requests, etc.) to ensure no regressions.🤖 Generated with Claude Code