Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variadic listen signature allows string port #4269

Merged
merged 2 commits into from Sep 12, 2022
Merged

Variadic listen signature allows string port #4269

merged 2 commits into from Sep 12, 2022

Conversation

marco-ippolito
Copy link
Contributor

@marco-ippolito marco-ippolito commented Sep 12, 2022

resolves: #4267

At the moment when using the variadic signature of listen and passing the port as a string, the port is converted to 0 even though the signature allows string as type.
With this PR it is possible to convert the port from string to number, and only in case the string cannot be parsed to a valid integer it converts it to 0.

Checklist

Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@@ -200,3 +200,26 @@ test('listen when firstArg is { path: string(pipe) } and with backlog and callba
t.equal(address, '\\\\.\\pipe\\testPipe3')
})
})

test('listen accepts a port as string, and callback', t => {
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a test that checks that random port still works fine?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added this test

@marco-ippolito marco-ippolito requested review from jsumners and simoneb and removed request for jsumners and simoneb September 12, 2022 16:18
@jsumners jsumners merged commit 9bac49d into fastify:main Sep 12, 2022
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Variadic listen signature is not working anymore
3 participants