Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
http: use listenerCount when adding noop event#46769
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
http: use listenerCount when adding noop event #46769
Conversation
nodejs-github-bot commented Feb 22, 2023
Review requested:
|
lpinca left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See discussion in #46523 (comment)
ShogunPanda commented Feb 22, 2023
I see your point about not being a bug in Node.js. I still think we should prevent the fix anyway. So, can please others gave a final vote on this? Other than that: do you have anything else you want me to change in this PR that I've lost in the discussion in the other issue? |
nodejs-github-bot commented Feb 22, 2023
lpinca commented Feb 22, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
The fix here actually hides the user error of keeping the socket open. If others think this is a good idea then I will dismiss my request for changes. The events leak warning might be unhelpful but at least it tells the user that there is something wrong. |
mcollina left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
ShogunPanda commented Feb 23, 2023
@nodejs/http Can somebody else upvote or downvote this so we can reach an agreement? |
mcollina commented Feb 23, 2023
There is a lot of legacy code out there that emits |
lpinca commented Feb 23, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
I disagree. Note that there is no crash, only a warning and this silences it. Instead of informing the user that there is something wrong in their code, this just ignores it. In my opinion it is not an improvement, it only promotes invalid usage. Just look at the second test added here. |
mcollina commented Feb 23, 2023
The problem is that the user must learn how to fix it. Most of those behaviors are codified in old libraries that are deep in the dependency chain, and it's close to impossible for most users to understand what's going on. My 2 cents is that we must convince them to switch from Node v0.8-era dependencies, as I don't expect those modules to be fixed. If we want to emit a warning for this case, it should be actionable, e.g. "an error event has already been emitted on the request. Please use the destroy method instead". |
lpinca commented Feb 23, 2023
Yes that would be perfect. Currently, a bad warning is better than no warning. |
ShogunPanda commented Feb 23, 2023
So I leave the "memory leak" prevention and I add an additional warning so the user is beware of the problematic handling. |
mcollina commented Feb 23, 2023
Yes, exactly! |
lpinca commented Feb 23, 2023
I have no objection with that. Note that there might be other cases where the |
ShogunPanda commented Feb 23, 2023
nodejs-github-bot commented Feb 23, 2023
dougwilson commented Feb 23, 2023
I have a question. The only code needed to make the original warning appear is the following: Refer to original #43548 for full reproduction steps. Does this mean that in order to make a basic Node.js http server will also require added a |
lpinca commented Feb 23, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Are you able to reproduce the issue with that test case?
No, because that is what Node.js does by default if the user does not add a listener for the |
dougwilson commented Feb 23, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Yes... I am using Jmeter from another machine. I will try it here on some various Node.js versions in a moment.
Ok, then I am confused here. This PR says it is suppsoed to fix #43548 but that issue is pretty basic and doesnt add |
lpinca commented Feb 23, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
I think the whole discussion originates from #43587 where a test case was added in the form of an invalid |
dougwilson commented Feb 23, 2023
I am trying to whittle down a simple ideally self-contained example to reproduce the conditions Jmeter is making with the load test. So far I at least seem to have a small example that shows what the consthttp=require('http')constserver=http.createServer((req,res)=>{res.end(JSON.stringify({hello: 'world'}))})server.listen(3000,'127.0.0.1')constnet=require('net')server.on('listening',()=>{constsocket=net.connect(3000,'127.0.0.1')socket.on('connect',()=>{socket.write('POST /s HTTP/1.1\r\nHost: localhost\r\nTransfer-Encoding: chunked\r\n\r\n')socket.resume()setTimeout(()=>{socket.end('z')},1000)})socket.on('close',()=>server.close())}) |
lpinca commented Feb 23, 2023
@dougwilson yes but that example does not cause the "leak" warning, does it? |
dougwilson commented Feb 23, 2023
No. I am trying to whittle down a simple ideally self-contained example to reproduce the conditions Jmeter is making with the load test. |
77a2064 to 196ec78CompareShogunPanda commented Feb 27, 2023
@lpinca I think the issue @dougwilson can eventually be handle as separate issue. Do you still want changes on this or are we good to go? |
lpinca commented Feb 27, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Yes, let's wait a little more for @dougwilson's feedback. |
ShogunPanda commented Mar 2, 2023
@lpinca No more input received. Shall we wait more or can we land this? |
lpinca commented Mar 2, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Wait a few more days, maybe @dougwilson is busy. It is not something that needs an immediate fix and I would prefer not to revert it again. |
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot commented Mar 5, 2023
Uh oh!
There was an error while loading. Please reload this page.
mcollina left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
nodejs-github-bot commented Mar 7, 2023
nodejs-github-bot commented Mar 8, 2023
Landed in 0d3faae |
PR-URL: #46769 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #46769 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #46769 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
Fixes#43548.
See discussion in #46523.