tls: remove unnecessary close listener …#34105
Closed
ronag wants to merge 1 commit intonodejs:masterfrom
Closed
Conversation
Wrapped streams are expected to behave the same as socket with handle. Remove unnecessary difference in handling.
Member
Author
|
As a side note... there is a lot that could be improved in the tls code... However, it's kind of risky and difficult to work with. Is this something we would like to do or should I just leave it alone? |
Collaborator
16 tasks
Collaborator
Member
I think it’s similar to streams – it’s hard to work with until somebody puts in a lot of work to clear it up. :/ |
addaleax
approved these changes
Jun 29, 2020
Collaborator
17 tasks
rickyes
approved these changes
Jun 30, 2020
27 tasks
trivikr
approved these changes
Jul 1, 2020
Collaborator
Collaborator
Member
Author
|
Landed in 60a217b |
ronag
added a commit
that referenced
this pull request
Jul 1, 2020
Wrapped streams are expected to behave the same as socket with handle. Remove unnecessary difference in handling. PR-URL: #34105 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
This was referenced Jul 2, 2020
This was referenced Jul 5, 2020
MylesBorins
pushed a commit
that referenced
this pull request
Jul 14, 2020
Wrapped streams are expected to behave the same as socket with handle. Remove unnecessary difference in handling. PR-URL: #34105 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Merged
MylesBorins
pushed a commit
that referenced
this pull request
Jul 16, 2020
Wrapped streams are expected to behave the same as socket with handle. Remove unnecessary difference in handling. PR-URL: #34105 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
addaleax
pushed a commit
that referenced
this pull request
Sep 22, 2020
Wrapped streams are expected to behave the same as socket with handle. Remove unnecessary difference in handling. PR-URL: #34105 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Merged
|
@ronag const http2 = require('http2')
const net = require('net')
const {Duplex} = require('stream')
class JsSocket extends Duplex {
constructor(socket) {
super({autoDestroy: true, allowHalfOpen: false})
socket.on('data', (data) => this.push(data))
socket.on('end', (data) => this.push(null))
socket.on('close', () => this.destroy())
this.socket = socket
}
unref() {}
ref() {}
setNoDelay() {}
setTimeout() {}
_write(data, encoding, callback) {
this.socket.write(data, encoding, callback)
}
_final(callback) {
callback()
}
_read(size) {}
_destroy(error, callback) {
callback()
}
}
const realSocket = net.connect({host: 'www.example.com', port: '443'},
() => {
console.log('connected')
const connection = http2.connect('https://www.example.com', {
socket: new JsSocket(realSocket), // crash!!!
// socket: realSocket, // but not crash!!!
})
const h2Stream = connection.request({[http2.constants.HTTP2_HEADER_PATH]: '/'})
setTimeout(() => {realSocket.destroy()}, 2e3)
setTimeout(() => {connection.close()}, 3e3)
}
)output: |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Wrapped streams are expected to behave the same as socket with handle.
Remove unnecessary difference in handling.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes