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

test: add net regression test #32794

Closed
wants to merge 2 commits into from
Closed

Conversation

ronag
Copy link
Member

@ronag ronag commented Apr 12, 2020

Ensure that the socket is not destroyed when the 'end' event is emitted

Refs: #32780 (comment)

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Apr 12, 2020
@ronag ronag added the net Issues and PRs related to the net subsystem. label Apr 12, 2020
@nodejs-github-bot
Copy link
Collaborator

@ronag
Copy link
Member Author

ronag commented Apr 12, 2020

This was fixed through a larger semver-major PR on master. This should not land in 14.x unless the referenced PR is included.

@lpinca
Copy link
Member

lpinca commented Apr 12, 2020

FWIW it is not destroyed before the 'end' event is emitted. It is destroyed after, but the listener where it is destroyed is the first one.

https://github.com/nodejs/node/blob/v13.12.0/lib/net.js#L629-L638

@ronag
Copy link
Member Author

ronag commented Apr 12, 2020

FWIW it is not destroyed before the 'end' event is emitted. It is destroyed after, but the listener where it is destroyed is the first one.

The observed behaviour for a user of the stream is that it is destroyed before 'end' is emitted.

@lpinca
Copy link
Member

lpinca commented Apr 12, 2020

Not if the user uses emitter.prependListener().

@ronag
Copy link
Member Author

ronag commented Apr 12, 2020

Not if the user uses emitter.prependListener().

I think using prependListener should be discouraged in general (and especially with streams) for this exact reason, it can break ordering assumptions (and also why stream implementations should preferably not depend on public events). Same thing applies with e.g. 'error' where if using prependListener('error') things can break in subtle ways.

I don't think prependListener is commonly used.

@lpinca
Copy link
Member

lpinca commented Apr 12, 2020

I think using prependListener should be discouraged in general for this exact reason, it can break ordering assumptions ...

While I partially agree, emitter.prependListener() was added and made public for this exact reason (break ordering assumptions).

@ronag
Copy link
Member Author

ronag commented Apr 12, 2020

was added and made public for this exact reason (break ordering assumptions).

Well, if you are using it you should know what you are doing... same with e.g. autoDestroy: false and emitClose: false... with great power...

I do think we should be more explicit about discouraging these things in the docs and make it clear you need to tread carefully.

@lpinca
Copy link
Member

lpinca commented Apr 12, 2020

I don't mind, I just find this commit message incorrect/misleading. Again the socket is not destroyed before the 'end' event is emitted.

@ronag
Copy link
Member Author

ronag commented Apr 12, 2020

I just find this commit message incorrect/misleading. Again the socket is not destroyed before the 'end' event is emitted.

The test tests that it is not destroyed before 'end' is emitted and it's a test to avoid future regressions. I'm unsure in what way it is misleading?

EDIT: Hm, I guess you are technically right, but it's a bit nit.

@lpinca
Copy link
Member

lpinca commented Apr 12, 2020

I suggest to use something like "Ensure that the socket is not destroyed when the 'end' event is emitted" to reflect what the test actually does.

Ensure that the socket is not destroyed when the 'end'
event is emitted.

Refs: nodejs#32780 (comment)
@ronag
Copy link
Member Author

ronag commented Apr 12, 2020

Updated

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Apr 12, 2020

CI: https://ci.nodejs.org/job/node-test-pull-request/30670/ (:yellow_circle:)

@ronag ronag added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 12, 2020
ronag added a commit that referenced this pull request Apr 14, 2020
Ensure that the socket is not destroyed when the 'end'
event is emitted.

Refs: #32780 (comment)

PR-URL: #32794
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@ronag
Copy link
Member Author

ronag commented Apr 14, 2020

Landed in cbe955c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. net Issues and PRs related to the net subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants