Repository navigation
fix(fastify): listen on a socket path - #18053
Merged
kamilmysliwiec merged 1 commit intoOct 9, 2026
Merged
Conversation
app.listen('/path/to.sock') crashed the process on the Fastify adapter.
Node threw a RangeError about a NaN port on a later tick. A try/catch
cannot catch it, and the message did not mention the socket path.
The cause is 522b991. It changed listen to pass { port: +port } for
the port argument. A path is not a number, so the port was NaN. Express
still listened on the same argument.
Now a string that is not a number becomes { path }. Numbers and numeric
strings still become { port }. The adapter sets no host for a path,
because the host does not apply to a socket. The object form is
unchanged.
Closes nestjs#18052
fengdi721
added a commit
to fengdi721/nest
that referenced
this pull request
Oct 8, 2026
Review nestjs#18053 locally (ci, mergeability, own repro test, mutation testing, edge cases versus node net.listen) and draft a review comment. Rehearse the full pr flow with a contributing.md fix opened against the fork. Add practices P26-P30 and a journal entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 of 4 tasks
1 of 2 tasks
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.
PR Checklist
PR Type
What is the current behavior?
Issue Number: #18052
Closes #18052
Hi! 👋 On the Fastify adapter,
app.listen('/path/to.sock')crashes the process with aRangeErrorabout aNaNport. The same call works on the Express adapter.FastifyAdapter.listen()turns every argument that is not an object into{ port: +value }. A path is not a number, so the port becomesNaN. This came with 522b991 in Nest 9. Before it, a socket path worked.I ran the repro on 12.1.2:
What is the new behavior?
A string that is not a number now becomes
{ path }. Numbers and numeric strings still become{ port }, and the object form does not change. The adapter does not pass a host with a path, because a host does not apply to a socket.The same repro against a local build of this branch:
Does this PR introduce a breaking change?
Only a non-numeric string changes, and it crashed the process before.
Other information
The specs cover these cases:
getUrl()returns thehttp+unix://form.One thing I left as is. When
listen()gets an options object and a host, the adapter writes the host into the caller's object. I am happy to look at it in a follow-up if you think it is worth it. 🙂