@@ -11,35 +11,18 @@ const h2 = require('http2');
1111const net = require ( 'net' ) ;
1212const { NghttpError } = require ( 'internal/http2/util' ) ;
1313const h2test = require ( '../common/http2' ) ;
14- let client ;
1514
1615const server = h2 . createServer ( ) ;
17- let gotFirstStreamId1 ;
1816server . on ( 'stream' , common . mustCall ( ( stream ) => {
1917 stream . respond ( ) ;
2018 stream . end ( 'ok' ) ;
2119
22- // Http2Server should be fast enough to respond to and close
23- // the first streams with ID 1 and ID 3 without errors.
24-
25- // Test for errors in 'close' event to ensure no errors on some streams.
26- stream . on ( 'error' , ( ) => { } ) ;
27- stream . on ( 'close' , ( err ) => {
28- if ( stream . id === 1 ) {
29- if ( gotFirstStreamId1 ) {
30- // We expect our outgoing frames to fail on Stream ID 1 the second time
31- // because a stream with ID 1 was already closed before.
32- common . expectsError ( {
33- constructor : NghttpError ,
34- code : 'ERR_HTTP2_ERROR' ,
35- message : 'Stream was already closed or invalid'
36- } ) ;
37- return ;
38- }
39- gotFirstStreamId1 = true ;
40- }
41- assert . strictEqual ( err , undefined ) ;
42- } ) ;
20+ stream . on ( 'error' , common . expectsError ( {
21+ code : 'ERR_HTTP2_ERROR' ,
22+ constructor : NghttpError ,
23+ message : 'Stream was already closed or invalid'
24+ } ) ) ;
25+ stream . on ( 'close' , common . mustCall ( ) ) ;
4326
4427 // Stream ID 5 should never reach the server
4528 assert . notStrictEqual ( stream . id , 5 ) ;
@@ -62,7 +45,7 @@ const id3 = new h2test.HeadersFrame(3, h2test.kFakeRequestHeaders, 0, true);
6245const id5 = new h2test . HeadersFrame ( 5 , h2test . kFakeRequestHeaders , 0 , true ) ;
6346
6447server . listen ( 0 , ( ) => {
65- client = net . connect ( server . address ( ) . port , ( ) => {
48+ const client = net . connect ( server . address ( ) . port , ( ) => {
6649 client . write ( h2test . kClientMagic , ( ) => {
6750 client . write ( settings . data , ( ) => {
6851 client . write ( settingsAck . data ) ;
0 commit comments