Skip to content

Conversation

@julianduque
Copy link
Contributor

Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

test, net

Description of change

Replace var to const/let, use common.mustCall on callbacks and move
process.on('exit') to the .on('error') handler

@julianduquejulianduque added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label Dec 1, 2016
@nodejs-github-botnodejs-github-bot added the test Issues and PRs related to the tests. label Dec 1, 2016
@julianduquejulianduque added the net Issues and PRs related to the net subsystem. label Dec 1, 2016
@imyllerimyller removed the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label Dec 1, 2016
@julianduquejulianduque added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label Dec 1, 2016
Copy link
Member

Choose a reason for hiding this comment

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

I think you could get rid of the exit listener if you assert in the error callback that e.code can only be EINVAL or ENOTSOCK

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@santigimeno do you suggest to do something like:

.on('error', common.mustCall(function(e){switch (e.code){case 'EINVAL': case 'ENOTSOCK': assert(e instanceof Error); break} 

Copy link
Member

@santigimenosantigimeno left a comment

Choose a reason for hiding this comment

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

LGTM with a suggestion

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you capitalize and punctuate the comment please.

@julianduque
Copy link
ContributorAuthor

Rebased with suggestions from @cjihrig and @santigimeno

@Fishrock123
Copy link
Contributor

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems incorrect to me. The previous behavior ran the assertion no matter what. The new behavior guarantees that an error is emitted, but not that it is the correct type. What if you just did:

assert(einstanceofError);assert(['EINVAL','ENOTSOCK'].includes(e.code));

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@cjihrig way better, I like it, just rebased with your suggestions

Replace var to const/let, use common.mustCall on callbacks and move process.on('exit') to the .on('error') handler
Copy link
Contributor

@cjihrigcjihrig left a comment

Choose a reason for hiding this comment

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

LGTM pending CI

@gibfahn
Copy link
Member

jasnell pushed a commit that referenced this pull request Dec 5, 2016
Replace var to const/let, use common.mustCall on callbacks and move process.on('exit') to the .on('error') handler PR-URL: #10025 Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
@jasnell
Copy link
Member

Landed in 1d766b8. Thank you for the PR and for participating in the code-and-learn!

@jasnelljasnell closed this Dec 5, 2016
@julianduquejulianduque deleted the test-net-listen-fd0 branch December 6, 2016 00:58
Fishrock123 pushed a commit that referenced this pull request Dec 6, 2016
Replace var to const/let, use common.mustCall on callbacks and move process.on('exit') to the .on('error') handler PR-URL: #10025 Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
addaleax pushed a commit to addaleax/node that referenced this pull request Dec 8, 2016
Replace var to const/let, use common.mustCall on callbacks and move process.on('exit') to the .on('error') handler PR-URL: nodejs#10025 Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
jmdarling pushed a commit to jmdarling/node that referenced this pull request Dec 8, 2016
Replace var to const/let, use common.mustCall on callbacks and move process.on('exit') to the .on('error') handler PR-URL: nodejs#10025 Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Dec 21, 2016
Replace var to const/let, use common.mustCall on callbacks and move process.on('exit') to the .on('error') handler PR-URL: #10025 Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
@MylesBorinsMylesBorins mentioned this pull request Dec 21, 2016
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-and-learnIssues related to the Code-and-Learn events and PRs submitted during the events.netIssues and PRs related to the net subsystem.testIssues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants

@julianduque@Fishrock123@gibfahn@jasnell@santigimeno@cjihrig@MylesBorins@addaleax@imyller@nodejs-github-bot