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

Suspected dead code in listenPromise #1099

Closed
trivikr opened this issue Aug 26, 2018 · 4 comments · Fixed by #1102
Closed

Suspected dead code in listenPromise #1099

trivikr opened this issue Aug 26, 2018 · 4 comments · Fixed by #1102
Labels
internals Change that won't impact the surface API.

Comments

@trivikr
Copy link
Member

trivikr commented Aug 26, 2018

You have already researched for similiar issues?

Yes

Are you sure this is an issue with the fastify or are you just looking for some help?

This seems to be a dead code in fastify

Is this a security related issue?

No

What are you trying to achieve or the steps to reproduce?

I was trying to add a test for covering the following line

address = address || 'localhost'

I noticed that the address can never be undefined as it's set to '127.0.0.1' is calling function

fastify/fastify.js

Lines 347 to 359 in 6bce249

if (typeof address === 'function') {
cb = address
address = undefined
}
address = address || '127.0.0.1'
/* Deal with listen (port, address, cb) */
if (typeof backlog === 'function') {
cb = backlog
backlog = undefined
}
if (cb === undefined) return listenPromise(port, address, backlog)

What did you expect?

Is the check on the following line redundant?

address = address || 'localhost'

@mcollina
Copy link
Member

Go ahead and remove it, it seems a duplicate!

@delvedor delvedor added the internals Change that won't impact the surface API. label Aug 26, 2018
@trivikr
Copy link
Member Author

trivikr commented Aug 26, 2018

The address = address || 'localhost' supposedly fixed the 500ms delay issue on Windows which was discussed and fixed in #1047

However, the current issue existed when the fix was introduced

Should '127.0.0.1' change to 'localhost' on line 351?

address = address || '127.0.0.1'

@mcollina
Copy link
Member

Yes it should. Actually, would you mind to refactor that check in just one place?

@trivikr
Copy link
Member Author

trivikr commented Aug 26, 2018

Fix posted in PR #1102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internals Change that won't impact the surface API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants