@@ -288,21 +288,6 @@ function onSessionClose(code, family, silent, statelessReset) {
288288 this [ owner_symbol ] [ kDestroy ] ( code , family , silent , statelessReset ) ;
289289}
290290
291- // Called by the C++ internals when a QuicSession has been destroyed.
292- // When this is called, the QuicSession is no longer usable. Removing
293- // the handle and emitting close is the only action.
294- // TODO(@jasnell): In the future, this will need to act differently
295- // for QuicClientSessions when autoResume is enabled.
296- function onSessionDestroyed ( ) {
297- const session = this [ owner_symbol ] ;
298- this [ owner_symbol ] = undefined ;
299-
300- if ( session ) {
301- session [ kSetHandle ] ( ) ;
302- process . nextTick ( emit . bind ( session , 'close' ) ) ;
303- }
304- }
305-
306291// Used only within the onSessionClientHello function. Invoked
307292// to complete the client hello process.
308293function clientHelloCallback ( err , ...args ) {
@@ -558,7 +543,6 @@ setCallbacks({
558543 onSessionCert,
559544 onSessionClientHello,
560545 onSessionClose,
561- onSessionDestroyed,
562546 onSessionHandshake,
563547 onSessionKeylog,
564548 onSessionQlog,
@@ -1908,28 +1892,26 @@ class QuicSession extends EventEmitter {
19081892 this . removeListener ( 'newListener' , onNewListener ) ;
19091893 this . removeListener ( 'removeListener' , onRemoveListener ) ;
19101894
1911- // If we are destroying with an error, schedule the
1912- // error to be emitted on process.nextTick.
1913- if ( error ) process . nextTick ( emit . bind ( this , 'error' , error ) ) ;
1914-
19151895 const handle = this [ kHandle ] ;
1916- this [ kHandle ] = undefined ;
1917-
1896+ this [ kHandle ] = undefined
19181897 if ( handle !== undefined ) {
19191898 // Copy the stats for use after destruction
19201899 state . stats = new BigInt64Array ( handle . stats ) ;
19211900 state . idleTimeout = this [ kInternalState ] . state . idleTimeout ;
19221901
19231902 // Destroy the underlying QuicSession handle
19241903 handle . destroy ( state . closeCode , state . closeFamily ) ;
1925- } else {
1926- process . nextTick ( emit . bind ( this , 'close' ) ) ;
19271904 }
19281905
19291906 // Remove the QuicSession JavaScript object from the
19301907 // associated QuicSocket.
19311908 state . socket [ kRemoveSession ] ( this ) ;
19321909 state . socket = undefined ;
1910+
1911+ // If we are destroying with an error, schedule the
1912+ // error to be emitted on process.nextTick.
1913+ if ( error ) process . nextTick ( emit . bind ( this , 'error' , error ) ) ;
1914+ process . nextTick ( emit . bind ( this , 'close' ) ) ;
19331915 }
19341916
19351917 // For server QuicSession instances, true if earlyData is
0 commit comments