Skip to content

Conversation

@indutny
Copy link
Member

@indutnyindutny commented Oct 12, 2016

Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

net

Description of change

end MUST always be emitted beforeclose. However, if a handle
will invoke uv_close_cb immediately, or in the same JS tick - close
may be emitted first.

cc @nodejs/collaborators

@nodejs-github-botnodejs-github-bot added the net Issues and PRs related to the net subsystem. label Oct 12, 2016
@mcollina
Copy link
Member

Nice one. I imagine there is very little chance to write a unit test for this, right?

if not, LGTM.

@indutny
Copy link
MemberAuthor

@mcollina I actually just got an idea on how to do this, but wanted to gather some preliminary feedback first.

@indutny
Copy link
MemberAuthor

Added test.

@Trott
Copy link
Member

@indutny Test not showing up here... (Forgot to push maybe? Or need to force-push maybe?)

`end` MUST always be emitted **before** `close`. However, if a handle will invoke `uv_close_cb` immediately, or in the same JS tick - `close` may be emitted first.
@indutnyindutnyforce-pushed the fix/ambiguity-in-net branch from 9920f17 to 6e38e76CompareOctober 12, 2016 22:36
@indutny
Copy link
MemberAuthor

@Trott sorry, just pushed it!

@indutny
Copy link
MemberAuthor

@Trott
Copy link
Member

Stress test to make sure there's no unexpected flakiness hidden in the test somewhere:

https://ci.nodejs.org/job/node-stress-single-test/994/

(Failures on the two win2008* jobs can be ignored, I think.)

@Trott
Copy link
Member

LGTM if no CI oddities arise.


process.on('exit', () =>{
assert.deepStrictEqual(events, [ 'end', 'close' ]);
});
Copy link
Member

Choose a reason for hiding this comment

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

Would something like this work?

s.on('end',common.mustCall(()=>{s.on('close',common.mustCall(()=>{}));}));

... so you can get rid of events and the exit listener.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

On one hand - yes, on the other - if this test will ever error, the error message will be more informative.

@mcollina
Copy link
Member

LGTM

Copy link
Member

@jasnelljasnell 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 green CI

Copy link
Member

@imyllerimyller left a comment

Choose a reason for hiding this comment

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

LGTM

@indutny
Copy link
MemberAuthor

Landed in 31196ea, thank you!

@indutnyindutny closed this Oct 14, 2016
@indutnyindutny deleted the fix/ambiguity-in-net branch October 14, 2016 13:40
indutny added a commit that referenced this pull request Oct 14, 2016
`end` MUST always be emitted **before** `close`. However, if a handle will invoke `uv_close_cb` immediately, or in the same JS tick - `close` may be emitted first. PR-URL: #9066 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ilkka Myller <[email protected]>
jasnell pushed a commit that referenced this pull request Oct 14, 2016
`end` MUST always be emitted **before** `close`. However, if a handle will invoke `uv_close_cb` immediately, or in the same JS tick - `close` may be emitted first. PR-URL: #9066 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ilkka Myller <[email protected]>
@MylesBorins
Copy link
Contributor

@indutny this lands cleanly on v4 and v6. Is this something we should consider backporting?

@indutny
Copy link
MemberAuthor

@thealphanerd yep

MylesBorins pushed a commit that referenced this pull request Nov 11, 2016
`end` MUST always be emitted **before** `close`. However, if a handle will invoke `uv_close_cb` immediately, or in the same JS tick - `close` may be emitted first. PR-URL: #9066 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ilkka Myller <[email protected]>
MylesBorins pushed a commit that referenced this pull request Nov 11, 2016
`end` MUST always be emitted **before** `close`. However, if a handle will invoke `uv_close_cb` immediately, or in the same JS tick - `close` may be emitted first. PR-URL: #9066 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ilkka Myller <[email protected]>
This was referenced Nov 22, 2016
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

netIssues and PRs related to the net subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@indutny@mcollina@Trott@MylesBorins@jasnell@santigimeno@imyller@cjihrig@nodejs-github-bot