@@ -1449,27 +1449,7 @@ class Http2Session extends EventEmitter {
1449
1449
}
1450
1450
1451
1451
_onTimeout ( ) {
1452
- // If the session is destroyed, this should never actually be invoked,
1453
- // but just in case...
1454
- if ( this . destroyed )
1455
- return ;
1456
- // This checks whether a write is currently in progress and also whether
1457
- // that write is actually sending data across the write. The kHandle
1458
- // stored `chunksSentSinceLastWrite` is only updated when a timeout event
1459
- // happens, meaning that if a write is ongoing it should never equal the
1460
- // newly fetched, updated value.
1461
- if ( this [ kState ] . writeQueueSize > 0 ) {
1462
- const handle = this [ kHandle ] ;
1463
- const chunksSentSinceLastWrite = handle !== undefined ?
1464
- handle . chunksSentSinceLastWrite : null ;
1465
- if ( chunksSentSinceLastWrite !== null &&
1466
- chunksSentSinceLastWrite !== handle . updateChunksSent ( ) ) {
1467
- this [ kUpdateTimer ] ( ) ;
1468
- return ;
1469
- }
1470
- }
1471
-
1472
- this . emit ( 'timeout' ) ;
1452
+ callTimeout ( this ) ;
1473
1453
}
1474
1454
1475
1455
ref ( ) {
@@ -1894,25 +1874,7 @@ class Http2Stream extends Duplex {
1894
1874
}
1895
1875
1896
1876
_onTimeout ( ) {
1897
- if ( this . destroyed )
1898
- return ;
1899
- // This checks whether a write is currently in progress and also whether
1900
- // that write is actually sending data across the write. The kHandle
1901
- // stored `chunksSentSinceLastWrite` is only updated when a timeout event
1902
- // happens, meaning that if a write is ongoing it should never equal the
1903
- // newly fetched, updated value.
1904
- if ( this [ kState ] . writeQueueSize > 0 ) {
1905
- const handle = this [ kSession ] [ kHandle ] ;
1906
- const chunksSentSinceLastWrite = handle !== undefined ?
1907
- handle . chunksSentSinceLastWrite : null ;
1908
- if ( chunksSentSinceLastWrite !== null &&
1909
- chunksSentSinceLastWrite !== handle . updateChunksSent ( ) ) {
1910
- this [ kUpdateTimer ] ( ) ;
1911
- return ;
1912
- }
1913
- }
1914
-
1915
- this . emit ( 'timeout' ) ;
1877
+ callTimeout ( this , kSession ) ;
1916
1878
}
1917
1879
1918
1880
// True if the HEADERS frame has been sent
@@ -2190,6 +2152,30 @@ class Http2Stream extends Duplex {
2190
2152
}
2191
2153
}
2192
2154
2155
+ function callTimeout ( self , kSession ) {
2156
+ // If the session is destroyed, this should never actually be invoked,
2157
+ // but just in case...
2158
+ if ( self . destroyed )
2159
+ return ;
2160
+ // This checks whether a write is currently in progress and also whether
2161
+ // that write is actually sending data across the write. The kHandle
2162
+ // stored `chunksSentSinceLastWrite` is only updated when a timeout event
2163
+ // happens, meaning that if a write is ongoing it should never equal the
2164
+ // newly fetched, updated value.
2165
+ if ( self [ kState ] . writeQueueSize > 0 ) {
2166
+ const handle = kSession ? self [ kSession ] [ kHandle ] : self [ kHandle ] ;
2167
+ const chunksSentSinceLastWrite = handle !== undefined ?
2168
+ handle . chunksSentSinceLastWrite : null ;
2169
+ if ( chunksSentSinceLastWrite !== null &&
2170
+ chunksSentSinceLastWrite !== handle . updateChunksSent ( ) ) {
2171
+ self [ kUpdateTimer ] ( ) ;
2172
+ return ;
2173
+ }
2174
+ }
2175
+
2176
+ self . emit ( 'timeout' ) ;
2177
+ }
2178
+
2193
2179
function callStreamClose ( stream ) {
2194
2180
stream . close ( ) ;
2195
2181
}
0 commit comments