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

lib: add an alias at addListener on Server connection socket #27325

Closed
wants to merge 1 commit into from

Conversation

himself65
Copy link
Member

@himself65 himself65 commented Apr 20, 2019

about #27199

socket.addListener should be the same behavior with socket.on

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

@nodejs-github-bot nodejs-github-bot added the http Issues or PRs related to the http subsystem. label Apr 20, 2019
@himself65 himself65 marked this pull request as ready for review April 20, 2019 15:19
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 21, 2019
Copy link
Member

@apapirovski apapirovski left a comment

Choose a reason for hiding this comment

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

This isn't a complete change. Code around line 748 also needs to be modified to add this line: this.addListener = net.Socket.prototype.addListener;

Personally I would also modify the relevant test (test-http-server-unconsume.js) to account for this change.

@apapirovski apapirovski removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 21, 2019
@himself65 himself65 force-pushed the master branch 3 times, most recently from 59dba46 to 9fd9921 Compare April 22, 2019 04:44
@himself65
Copy link
Member Author

@apapirovski fixed

@Antonius-S
Copy link

Isn't more gentle and logical to add newlistener listener instead? And how about prependListener?

@himself65
Copy link
Member Author

himself65 commented Apr 22, 2019

Isn't more gentle and logical to add newlistener listener instead? And how about prependListener?

why?

all this extend EventEmitter class

and all behavior should be the same as EventEmitter, or It will cause the disorganized behavior and namespace problem

node/lib/events.js

Lines 269 to 273 in 2161690

EventEmitter.prototype.addListener = function addListener(type, listener) {
return _addListener(this, type, listener, false);
};
EventEmitter.prototype.on = EventEmitter.prototype.addListener;

Copy link
Member

@apapirovski apapirovski left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@ZYSzys ZYSzys added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 24, 2019
@ZYSzys
Copy link
Member

ZYSzys commented Apr 25, 2019

@Antonius-S @SimonSchick Hi, did you have any other thought on this ? Otherwise we'll land this.

@SimonSchick
Copy link
Contributor

@ZYSzys Imo this is not a fix but just a band-aid/work-around, this should be fixed using the new listener event.
Otherwise the same issue will occur for prependListener etc.

Also doesn't that break off and removeEventListener?

I don't really have any authority here and therefor won't block anything but I don't think this should be merged.

@himself65
Copy link
Member Author

@SimonSchick
emmm, I have a new idea that use Object​.define​Property() to bind functions on EventEmitter
And I will create a new pull request in the few days

@himself65
Copy link
Member Author

@SimonSchick
I did further modifications at #27427, How would you think of it?

@apapirovski
Copy link
Member

apapirovski commented Apr 27, 2019

@himself65 imo that PR is a step back. Just add prependListener here if needed. I don’t see what other edge cases there are tbh.

Otherwise, yes we could use an event for newListener but that’s a lot more work... I dunno. Seems like semantics.

Also as far as I can tell the main reason to not use events here would be performance.

@Trott Trott removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 30, 2019
@Trott
Copy link
Member

Trott commented Apr 30, 2019

I removed author ready pending the prependListener() fix, but if someone else thinks that shouldn't block this, by all means, go ahead and land it.

@himself65
Copy link
Member Author

@Trott added

@himself65 himself65 force-pushed the master branch 2 times, most recently from 027b976 to f4d2da6 Compare May 1, 2019 07:11
Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

LGTM. Could add Fixes: https://github.com/nodejs/node/issues/27199 to the commit message?

@Trott Trott added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 2, 2019
@nodejs-github-bot

This comment has been minimized.

@himself65
Copy link
Member Author

LGTM. Could add Fixes: https://github.com/nodejs/node/issues/27199 to the commit message?

sure

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@himself65
Copy link
Member Author

no one to merge this?

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@addaleax
Copy link
Member

Landed in be26f6e, thanks for the PR! 🎉

(Changed the ommit message changed to begin with http: while landing)

@addaleax addaleax closed this May 19, 2019
addaleax pushed a commit that referenced this pull request May 19, 2019
Fixes: #27199

PR-URL: #27325
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
targos pushed a commit that referenced this pull request May 20, 2019
Fixes: #27199

PR-URL: #27325
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@BridgeAR BridgeAR mentioned this pull request May 21, 2019
4 tasks
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. http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.