-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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,http: fix http dump test #19823
Conversation
@@ -560,7 +560,7 @@ function resOnFinish(req, res, socket, state, server) { | |||
// if the user never called req.read(), and didn't pipe() or | |||
// .resume() or .on('data'), then we call req._dump() so that the | |||
// bytes will be pulled off the wire. | |||
if (!req._consuming && !req._readableState.resumeScheduled) | |||
if (!req._readableState.resumeScheduled) |
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.
this was noted in the original PR. req._consuming
is never set.
req.on('error', function(err) { | ||
// ECONNRESET can happen if there is some data still | ||
// being sent, as the other side is calling .destroy() | ||
if (err.code !== 'ECONNRESET') { |
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.
I think on Windows it's ECONNABORTED
, and it might also be EPIPE
as per #19139 (comment). Should we just ignore the error?
req.on('end', common.mustNotCall); | ||
|
||
// this 'data' handler will be removed when dumped | ||
req.on('data', common.mustNotCall); |
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.
Can we still check that _dump()
removes all data listeners?
Line 299 in 354849e
this.removeAllListeners('data'); |
maybe adding an assertion for listenerCount('data')
in the 'resume'
handler?
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.
Added
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.
Added a few more comments. All nits that can be ignored.
req.on('resume', common.mustCall(function() { | ||
// there is no 'data' event handler anymore | ||
// it gets automatically removed when dumping the request | ||
assert.strictEqual(req.listenerCount('data'), 0); | ||
console.log('resume called'); |
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.
Nit: This can be safely removed as the listener is wrapped in mustCall()
.
const fs = require('fs'); | ||
|
||
let resEnd = null; | ||
|
||
const server = http.createServer(function(req, res) { |
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.
Nit: I'd wrap the listener with mustCall()
.
req.on('resume', common.mustCall(function() { | ||
// there is no 'data' event handler anymore | ||
// it gets automatically removed when dumping the request | ||
assert.strictEqual(req.listenerCount('data'), 0); | ||
console.log('resume called'); | ||
|
||
req.on('data', common.mustCallAtLeast(function(d) { | ||
console.log('data', d); |
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.
Nit: this could also be removed.
// this checks if the request gets dumped | ||
// resume will be triggered by res.end() |
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.
Nit: would you be so kind and punctuate each sentence and also use a capital letter for the first character of a sentence? :-) That applies to all comments in here. The reason is that it is hard to see the beginning and the end of each sentence right now.
c93afee
to
010c26c
Compare
(I imagine this also fixes the |
010c26c
to
37ae792
Compare
CI after rebase: https://ci.nodejs.org/job/node-test-pull-request/14112/ |
Do we? I don't think this is still flaky after this rewrite. |
I don’t think #19819 was needed. |
37ae792
to
8e245ea
Compare
Landed as 1f29963 |
It was needed. I landed this PR on top of master locally on my machine and ran the test under system load and it was still failing. |
Here's the demo that this alone wasn't enough to fix the test for parallel runs:
|
Fix test-http-dump-req-when-res-ends and move it back to test/parallel/ Refs: nodejs#19823
@Trott on my Macbook:
So, something weirder was at play here, but I think @lpinca is on to something in #19866. |
@mcollina Try a bigger |
Make sure the dump test actually verify what is happening and it is not flaky. See: nodejs#19139 PR-URL: nodejs#19823 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Fixes: #19139
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes