-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
net: autoDestroy Socket #31806
Closed
Closed
net: autoDestroy Socket #31806
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
|
||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
const net = require('net'); | ||
|
||
|
@@ -31,10 +32,7 @@ const server = net.createServer(common.mustCall(function(socket) { | |
|
||
socket.resume(); | ||
|
||
socket.on('error', common.mustCall(function(error) { | ||
console.error('received error as expected, closing server', error); | ||
server.close(); | ||
})); | ||
socket.on('error', common.mustNotCall()); | ||
})); | ||
|
||
server.listen(0, function() { | ||
|
@@ -44,7 +42,10 @@ server.listen(0, function() { | |
// Then 'end' will be emitted when it receives a FIN packet from | ||
// the other side. | ||
client.on('end', common.mustCall(() => { | ||
serverSocket.write('test', common.mustCall()); | ||
serverSocket.write('test', common.mustCall((err) => { | ||
assert(err); | ||
server.close(); | ||
})); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
})); | ||
client.end(); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,9 +59,8 @@ const net = require('net'); | |
assert.strictEqual(client.bufferSize, i + 1); | ||
} | ||
|
||
// It seems that tlsSockets created from sockets of `Duplex` emit no | ||
// "finish" events. We use "end" event instead. | ||
client.on('end', common.mustCall(() => { | ||
client.on('end', common.mustCall()); | ||
client.on('close', common.mustCall(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
assert.strictEqual(client.bufferSize, undefined); | ||
})); | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@lundibundi Could you take a look here? The readable side of the connection cleanly ends, cleanups the conn and thus never errors. Fix is to not destroy on
'end'
. Does that somehow invalidate the test?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.
Related to: #30505
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.
@ronag Sorry for the late response, I missed this one. I'm not sure I understand the reasons for this
The server connection handler shouldn't be called as we are only sending 'close stream' packets (and never open a stream which is therefore invalid) and we don't
.end
\.destroy
the connection on the client-side. Something doesn't feel right here, not sure though.As for the test itself, I think it will be fine either way and shouldn't be affected.
/cc @addaleax as the author of the original test (test-http2-reset-flood)
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’m not sure I understand why this is necessary either, but I agree that the test functionality shouldn’t be affected – the important thing is that the
.once('error')
handler below fires.