@@ -1129,6 +1129,8 @@ class Http2Session extends EventEmitter {
1129
1129
if ( ! socket . _handle || ! socket . _handle . isStreamBase ) {
1130
1130
socket = new JSStreamSocket ( socket ) ;
1131
1131
}
1132
+ socket . on ( 'error' , socketOnError ) ;
1133
+ socket . on ( 'close' , socketOnClose ) ;
1132
1134
1133
1135
// No validation is performed on the input parameters because this
1134
1136
// constructor is not exported directly for users.
@@ -2909,9 +2911,6 @@ function connectionListener(socket) {
2909
2911
return ;
2910
2912
}
2911
2913
2912
- socket . on ( 'error' , socketOnError ) ;
2913
- socket . on ( 'close' , socketOnClose ) ;
2914
-
2915
2914
// Set up the Session
2916
2915
const session = new ServerHttp2Session ( options , socket , this ) ;
2917
2916
@@ -3134,12 +3133,6 @@ function connect(authority, options, listener) {
3134
3133
3135
3134
const session = new ClientHttp2Session ( options , socket ) ;
3136
3135
3137
- // ClientHttp2Session may create a new socket object
3138
- // when socket is a JSSocket (socket != kSocket)
3139
- // https://github.com/nodejs/node/issues/35695
3140
- session [ kSocket ] . on ( 'error' , socketOnError ) ;
3141
- session [ kSocket ] . on ( 'close' , socketOnClose ) ;
3142
-
3143
3136
session [ kAuthority ] = `${ options . servername || host } :${ port } ` ;
3144
3137
session [ kProtocol ] = protocol ;
3145
3138
0 commit comments