@@ -1460,27 +1460,7 @@ class Http2Session extends EventEmitter {
1460
1460
}
1461
1461
1462
1462
_onTimeout ( ) {
1463
- // If the session is destroyed, this should never actually be invoked,
1464
- // but just in case...
1465
- if ( this . destroyed )
1466
- return ;
1467
- // This checks whether a write is currently in progress and also whether
1468
- // that write is actually sending data across the write. The kHandle
1469
- // stored `chunksSentSinceLastWrite` is only updated when a timeout event
1470
- // happens, meaning that if a write is ongoing it should never equal the
1471
- // newly fetched, updated value.
1472
- if ( this [ kState ] . writeQueueSize > 0 ) {
1473
- const handle = this [ kHandle ] ;
1474
- const chunksSentSinceLastWrite = handle !== undefined ?
1475
- handle . chunksSentSinceLastWrite : null ;
1476
- if ( chunksSentSinceLastWrite !== null &&
1477
- chunksSentSinceLastWrite !== handle . updateChunksSent ( ) ) {
1478
- this [ kUpdateTimer ] ( ) ;
1479
- return ;
1480
- }
1481
- }
1482
-
1483
- this . emit ( 'timeout' ) ;
1463
+ callTimeout ( this ) ;
1484
1464
}
1485
1465
1486
1466
ref ( ) {
@@ -1906,25 +1886,7 @@ class Http2Stream extends Duplex {
1906
1886
}
1907
1887
1908
1888
_onTimeout ( ) {
1909
- if ( this . destroyed )
1910
- return ;
1911
- // This checks whether a write is currently in progress and also whether
1912
- // that write is actually sending data across the write. The kHandle
1913
- // stored `chunksSentSinceLastWrite` is only updated when a timeout event
1914
- // happens, meaning that if a write is ongoing it should never equal the
1915
- // newly fetched, updated value.
1916
- if ( this [ kState ] . writeQueueSize > 0 ) {
1917
- const handle = this [ kSession ] [ kHandle ] ;
1918
- const chunksSentSinceLastWrite = handle !== undefined ?
1919
- handle . chunksSentSinceLastWrite : null ;
1920
- if ( chunksSentSinceLastWrite !== null &&
1921
- chunksSentSinceLastWrite !== handle . updateChunksSent ( ) ) {
1922
- this [ kUpdateTimer ] ( ) ;
1923
- return ;
1924
- }
1925
- }
1926
-
1927
- this . emit ( 'timeout' ) ;
1889
+ callTimeout ( this , kSession ) ;
1928
1890
}
1929
1891
1930
1892
// True if the HEADERS frame has been sent
@@ -2202,6 +2164,30 @@ class Http2Stream extends Duplex {
2202
2164
}
2203
2165
}
2204
2166
2167
+ function callTimeout ( self , kSession ) {
2168
+ // If the session is destroyed, this should never actually be invoked,
2169
+ // but just in case...
2170
+ if ( self . destroyed )
2171
+ return ;
2172
+ // This checks whether a write is currently in progress and also whether
2173
+ // that write is actually sending data across the write. The kHandle
2174
+ // stored `chunksSentSinceLastWrite` is only updated when a timeout event
2175
+ // happens, meaning that if a write is ongoing it should never equal the
2176
+ // newly fetched, updated value.
2177
+ if ( self [ kState ] . writeQueueSize > 0 ) {
2178
+ const handle = kSession ? self [ kSession ] [ kHandle ] : self [ kHandle ] ;
2179
+ const chunksSentSinceLastWrite = handle !== undefined ?
2180
+ handle . chunksSentSinceLastWrite : null ;
2181
+ if ( chunksSentSinceLastWrite !== null &&
2182
+ chunksSentSinceLastWrite !== handle . updateChunksSent ( ) ) {
2183
+ self [ kUpdateTimer ] ( ) ;
2184
+ return ;
2185
+ }
2186
+ }
2187
+
2188
+ self . emit ( 'timeout' ) ;
2189
+ }
2190
+
2205
2191
function callStreamClose ( stream ) {
2206
2192
stream . close ( ) ;
2207
2193
}
0 commit comments