@@ -457,21 +457,10 @@ function onHTTP2GoAway (code) {
457
457
client [ kSocket ] = null
458
458
client [ kHTTP2Session ] = null
459
459
460
- if ( client . destroyed ) {
461
- assert ( this [ kPending ] === 0 )
462
-
463
- // Fail entire queue.
464
- const requests = client [ kQueue ] . splice ( client [ kRunningIdx ] )
465
- for ( let i = 0 ; i < requests . length ; i ++ ) {
466
- const request = requests [ i ]
467
- errorRequest ( this , request , err )
468
- }
469
- } else if ( client [ kRunning ] > 0 ) {
470
- // Fail head of pipeline.
471
- const request = client [ kQueue ] [ client [ kRunningIdx ] ]
472
- client [ kQueue ] [ client [ kRunningIdx ] ++ ] = null
473
-
474
- errorRequest ( client , request , err )
460
+ const requests = client [ kQueue ] . splice ( client [ kRunningIdx ] )
461
+ for ( let i = 0 ; i < requests . length ; i ++ ) {
462
+ const request = requests [ i ]
463
+ errorRequest ( this , request , err )
475
464
}
476
465
477
466
client [ kPendingIdx ] = client [ kRunningIdx ]
@@ -1089,7 +1078,9 @@ function onSocketClose () {
1089
1078
1090
1079
client [ kSocket ] = null
1091
1080
1092
- if ( client . destroyed ) {
1081
+ // TODO (fix): Always fail entire queue
1082
+
1083
+ if ( client . destroyed || client [ kHTTPConnVersion ] === 'h2' ) {
1093
1084
assert ( client [ kPending ] === 0 )
1094
1085
1095
1086
// Fail entire queue.
@@ -1325,8 +1316,10 @@ function _resume (client, sync) {
1325
1316
return
1326
1317
}
1327
1318
1328
- if ( client [ kRunning ] >= ( client [ kPipelining ] || 1 ) ) {
1329
- return
1319
+ if ( client [ kHTTPConnVersion ] === 'h1' ) {
1320
+ if ( client [ kRunning ] >= ( client [ kPipelining ] || 1 ) ) {
1321
+ return
1322
+ }
1330
1323
}
1331
1324
1332
1325
const request = client [ kQueue ] [ client [ kPendingIdx ] ]
@@ -1353,35 +1346,41 @@ function _resume (client, sync) {
1353
1346
return
1354
1347
}
1355
1348
1356
- if ( socket . destroyed || socket [ kWriting ] || socket [ kReset ] || socket [ kBlocking ] ) {
1349
+ if ( socket . destroyed ) {
1357
1350
return
1358
1351
}
1359
1352
1360
- if ( client [ kRunning ] > 0 && ! request . idempotent ) {
1361
- // Non-idempotent request cannot be retried.
1362
- // Ensure that no other requests are inflight and
1363
- // could cause failure.
1364
- return
1365
- }
1353
+ if ( client [ kHTTPConnVersion ] === 'h1' ) {
1354
+ if ( socket [ kWriting ] || socket [ kReset ] || socket [ kBlocking ] ) {
1355
+ return
1356
+ }
1366
1357
1367
- if ( client [ kRunning ] > 0 && ( request . upgrade || request . method === 'CONNECT' ) ) {
1368
- // Don't dispatch an upgrade until all preceding requests have completed .
1369
- // A misbehaving server might upgrade the connection before all pipelined
1370
- // request has completed .
1371
- return
1372
- }
1358
+ if ( client [ kRunning ] > 0 && ! request . idempotent ) {
1359
+ // Non-idempotent request cannot be retried .
1360
+ // Ensure that no other requests are inflight and
1361
+ // could cause failure .
1362
+ return
1363
+ }
1373
1364
1374
- if ( client [ kRunning ] > 0 && util . bodyLength ( request . body ) !== 0 &&
1375
- ( util . isStream ( request . body ) || util . isAsyncIterable ( request . body ) || util . isFormDataLike ( request . body ) ) ) {
1376
- // Request with stream or iterator body can error while other requests
1377
- // are inflight and indirectly error those as well .
1378
- // Ensure this doesn't happen by waiting for inflight
1379
- // to complete before dispatching.
1365
+ if ( client [ kRunning ] > 0 && ( request . upgrade || request . method === 'CONNECT' ) ) {
1366
+ // Don't dispatch an upgrade until all preceding requests have completed.
1367
+ // A misbehaving server might upgrade the connection before all pipelined
1368
+ // request has completed .
1369
+ return
1370
+ }
1380
1371
1381
- // Request with stream or iterator body cannot be retried.
1382
- // Ensure that no other requests are inflight and
1383
- // could cause failure.
1384
- return
1372
+ if ( client [ kRunning ] > 0 && util . bodyLength ( request . body ) !== 0 &&
1373
+ ( util . isStream ( request . body ) || util . isAsyncIterable ( request . body ) || util . isFormDataLike ( request . body ) ) ) {
1374
+ // Request with stream or iterator body can error while other requests
1375
+ // are inflight and indirectly error those as well.
1376
+ // Ensure this doesn't happen by waiting for inflight
1377
+ // to complete before dispatching.
1378
+
1379
+ // Request with stream or iterator body cannot be retried.
1380
+ // Ensure that no other requests are inflight and
1381
+ // could cause failure.
1382
+ return
1383
+ }
1385
1384
}
1386
1385
1387
1386
if ( ! request . aborted && write ( client , request ) ) {
0 commit comments