Skip to content

types: Allow port to be null in request type definition#6589

Merged
jean-michelet merged 2 commits intofastify:mainfrom
TristanBarlow:types-port-update
Mar 17, 2026
Merged

types: Allow port to be null in request type definition#6589
jean-michelet merged 2 commits intofastify:mainfrom
TristanBarlow:types-port-update

Conversation

@TristanBarlow
Copy link
Copy Markdown
Contributor

When testing in an environment where the connection does not contain an explicit port number the req.port value is null. This I believe is due to a fallback value of null that can be seen here:

return null

This PR corrects the port type to represent that the value can be null.

Checklist

@github-actions github-actions bot added the typescript TypeScript related label Mar 16, 2026
@TristanBarlow TristanBarlow marked this pull request as ready for review March 16, 2026 12:52
Copy link
Copy Markdown
Member

@jean-michelet jean-michelet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may break some CIs. But type level changes are not covered by our breaking change policy.

@jean-michelet
Copy link
Copy Markdown
Member

Sorry, I forgot to run the CI.
You need to add a test for this plz.

Copy link
Copy Markdown
Member

@jean-michelet jean-michelet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing tests.

@TristanBarlow
Copy link
Copy Markdown
Contributor Author

TristanBarlow commented Mar 17, 2026

Missing tests.

@jean-michelet thank you for reviewing and my apologies for the failing test, I did not realise there are type tests.
I have updated the failing test to check that the port type is number | null e368739.

Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jean-michelet jean-michelet merged commit 9cc5187 into fastify:main Mar 17, 2026
32 checks passed
@TristanBarlow TristanBarlow deleted the types-port-update branch March 17, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

typescript TypeScript related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants