@@ -13,7 +13,7 @@ const { Worker, parentPort } = require('worker_threads');
13
13
// the two event loops intermixing, as we are writing in a busy loop here.
14
14
15
15
if ( process . env . HAS_STARTED_WORKER ) {
16
- const server = http2 . createServer ( ) ;
16
+ const server = http2 . createServer ( { maxSessionInvalidFrames : 100 } ) ;
17
17
server . on ( 'stream' , ( stream ) => {
18
18
stream . respond ( {
19
19
'content-type' : 'text/plain' ,
@@ -59,19 +59,22 @@ const worker = new Worker(__filename).on('message', common.mustCall((port) => {
59
59
} ) ;
60
60
61
61
let gotError = false ;
62
+ let streamId = 1 ;
62
63
63
64
function writeRequests ( ) {
64
- for ( let i = 1 ; ! gotError ; i += 2 ) {
65
+ for ( let i = 1 ; i < 10 && ! gotError ; i ++ ) {
65
66
h2header [ 3 ] = 1 ; // HEADERS
66
67
h2header [ 4 ] = 0x5 ; // END_HEADERS|END_STREAM
67
68
h2header . writeIntBE ( 1 , 0 , 3 ) ; // Length: 1
68
- h2header . writeIntBE ( i , 5 , 4 ) ; // Stream ID
69
+ h2header . writeIntBE ( streamId , 5 , 4 ) ; // Stream ID
70
+ streamId += 2 ;
69
71
// 0x88 = :status: 200
70
72
if ( ! conn . write ( Buffer . concat ( [ h2header , Buffer . from ( [ 0x88 ] ) ] ) ) ) {
71
- process . nextTick ( writeRequests ) ;
72
73
break ;
73
74
}
74
75
}
76
+ if ( ! gotError )
77
+ setImmediate ( writeRequests ) ;
75
78
}
76
79
77
80
conn . once ( 'error' , common . mustCall ( ( ) => {
0 commit comments