Skip to content

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

Closed
himself65 wants to merge 1 commit into
nodejs:masterfrom
himself65:master
Closed

lib: add an alias at addListener on Server connection socket#27325
himself65 wants to merge 1 commit into
nodejs:masterfrom
himself65:master

Conversation

@himself65

@himself65himself65 commented Apr 20, 2019

Copy link
Copy Markdown
Member

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-botnodejs-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.

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

@apapirovskiapapirovski left a comment

Copy link
Copy Markdown
Contributor

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.

@apapirovskiapapirovski 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
himself65force-pushed the master branch 3 times, most recently from 59dba46 to 9fd9921CompareApril 22, 2019 04:44
@himself65

Copy link
Copy Markdown
MemberAuthor

@apapirovski fixed

@Antonius-S

Copy link
Copy Markdown

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

@himself65

himself65 commented Apr 22, 2019

Copy link
Copy Markdown
MemberAuthor

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=functionaddListener(type,listener){
return_addListener(this,type,listener,false);
};
EventEmitter.prototype.on=EventEmitter.prototype.addListener;

Comment threadtest/parallel/test-http-server-unconsume.js Outdated

@apapirovskiapapirovski left a comment

Copy link
Copy Markdown
Contributor

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.

@ZYSzysZYSzys 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

ZYSzys commented Apr 25, 2019

Copy link
Copy Markdown
Member

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

@SimonSchick

Copy link
Copy Markdown
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
Copy Markdown
MemberAuthor

@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

@himself65himself65 mentioned this pull request Apr 26, 2019
3 tasks
@himself65

Copy link
Copy Markdown
MemberAuthor

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

@apapirovski

apapirovski commented Apr 27, 2019

Copy link
Copy Markdown
Contributor

@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.

@TrottTrott 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
Copy Markdown
Member

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
Copy Markdown
MemberAuthor

@Trott added

Comment threadtest/parallel/test-http-server-unconsume.js Outdated
@himself65
himself65force-pushed the master branch 2 times, most recently from 027b976 to f4d2da6CompareMay 1, 2019 07:11

@TrottTrott left a comment

Copy link
Copy Markdown
Member

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?

@TrottTrott 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
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

no one to merge this?

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@addaleax

Copy link
Copy Markdown
Member

Landed in be26f6e, thanks for the PR! 🎉

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

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>
@BridgeARBridgeAR mentioned this pull request May 21, 2019
4 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.httpIssues or PRs related to the http subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

12 participants

@himself65@nodejs-github-bot@Antonius-S@ZYSzys@SimonSchick@apapirovski@Trott@addaleax@jasnell@lpinca@cjihrig@BridgeAR