@@ -54,9 +54,6 @@ class QUICStream
54
54
// This resolves when `streamRecv` results in a `StreamReset(u64)` or a fin flag indicating receiving has ended
55
55
protected recvFinishedProm = utils . promise < void > ( ) ;
56
56
57
- protected sentBytes : number = 0 ;
58
- protected recvBytes : number = 0 ;
59
-
60
57
/**
61
58
* For `reasonToCode`, return 0 means "unknown reason"
62
59
* It is the catch-all for codes.
@@ -131,13 +128,6 @@ class QUICStream
131
128
this . reasonToCode = reasonToCode ;
132
129
this . codeToReason = codeToReason ;
133
130
134
- this . sendFinishedProm . p . finally ( ( ) =>
135
- logger . info ( 'sendFinishedProm resolved' ) ,
136
- ) ;
137
- this . recvFinishedProm . p . finally ( ( ) =>
138
- logger . info ( 'recvFinishedProm resolved' ) ,
139
- ) ;
140
-
141
131
this . readable = new ReadableStream (
142
132
{
143
133
type : 'bytes' ,
@@ -146,7 +136,6 @@ class QUICStream
146
136
this . readableController = controller ;
147
137
} ,
148
138
pull : async ( ) => {
149
- this . logger . info ( 'doing pull' ) ;
150
139
this . _recvPaused = false ;
151
140
} ,
152
141
cancel : async ( reason ) => {
@@ -173,7 +162,7 @@ class QUICStream
173
162
// with the `fin` set to true
174
163
// If this itself results in an error, we can continue
175
164
// But continue to do the below
176
- this . logger . info ( 'sending fin frame' ) ;
165
+ this . logger . debug ( 'sending fin frame' ) ;
177
166
// This.sendFinishedProm.resolveP();
178
167
await this . streamSend ( Buffer . from ( [ 0 ] ) , true ) . catch ( ( e ) => {
179
168
// Ignore send error if stream is already closed
@@ -350,15 +339,13 @@ class QUICStream
350
339
void this . closeSend ( true , err ) . catch ( ( ) => { } ) ;
351
340
}
352
341
} ) ;
353
- this . logger . debug ( 'send FINISHED' ) ;
354
342
return true ;
355
343
}
356
344
}
357
345
358
346
protected async streamRecv ( ) : Promise < void > {
359
347
const buf = Buffer . alloc ( 1024 ) ;
360
348
let recvLength : number , fin : boolean ;
361
- this . logger . debug ( 'trying receiving' ) ;
362
349
while ( true ) {
363
350
try {
364
351
[ recvLength , fin ] = this . conn . streamRecv ( this . streamId , buf ) ;
@@ -374,7 +361,7 @@ class QUICStream
374
361
// This should never be reported... (this branch should be dead code)
375
362
return ;
376
363
} else {
377
- this . logger . info ( `Stream recv reported: error ${ e . message } ` ) ;
364
+ this . logger . debug ( `Stream recv reported: error ${ e . message } ` ) ;
378
365
// Signal receiving has ended
379
366
this . recvFinishedProm . resolveP ( ) ;
380
367
if ( ! this . _recvClosed ) {
@@ -394,27 +381,20 @@ class QUICStream
394
381
return ;
395
382
}
396
383
}
397
- this . recvBytes += recvLength ;
398
- this . logger . info ( `recv bytes ${ this . recvBytes } ` ) ;
399
- this . logger . info ( `fin? ${ fin } ` ) ;
400
384
// If fin is true, then that means, the stream is CLOSED
401
385
if ( ! fin ) {
402
386
// Send the data normally
403
387
if ( ! this . _recvClosed ) {
404
388
this . readableController . enqueue ( buf . subarray ( 0 , recvLength ) ) ;
405
389
}
406
390
} else {
407
- this . logger . info ( 'finishing' ) ;
408
391
// Strip the end message, removing the null byte
409
392
if ( ! this . _recvClosed && recvLength > 1 ) {
410
- this . logger . info ( 'finish contained message' ) ;
411
393
this . readableController . enqueue ( buf . subarray ( 0 , recvLength - 1 ) ) ;
412
394
}
413
395
// This will render `stream.cancel` a noop
414
- this . logger . info ( 'closing' ) ;
415
396
if ( ! this . _recvClosed ) this . readableController . close ( ) ;
416
397
await this . closeRecv ( ) ;
417
- this . logger . info ( 'closed' ) ;
418
398
// Signal receiving has ended
419
399
this . recvFinishedProm . resolveP ( ) ;
420
400
return ;
@@ -472,8 +452,6 @@ class QUICStream
472
452
}
473
453
}
474
454
}
475
- if ( sentLength > 0 ) this . sentBytes += sentLength ;
476
- this . logger . info ( `sent bytes ${ this . sentBytes } ` ) ;
477
455
if ( sentLength < chunk . length ) {
478
456
const { p : writableP , resolveP : resolveWritableP } = utils . promise ( ) ;
479
457
this . resolveWritableP = resolveWritableP ;
@@ -495,10 +473,10 @@ class QUICStream
495
473
isError : boolean = false ,
496
474
reason ?: any ,
497
475
) : Promise < void > {
498
- if ( isError ) this . logger . info ( `recv closed with error ${ reason . message } ` ) ;
476
+ if ( isError ) this . logger . debug ( `recv closed with error ${ reason . message } ` ) ;
499
477
// Further closes are NOPs
500
478
if ( this . _recvClosed ) return ;
501
- this . logger . info ( `Close Recv` ) ;
479
+ this . logger . debug ( `Close Recv` ) ;
502
480
// Indicate that the receiving side is closed
503
481
this . _recvClosed = true ;
504
482
const code = isError ? await this . reasonToCode ( 'send' , reason ) : 0 ;
@@ -530,10 +508,10 @@ class QUICStream
530
508
isError : boolean = false ,
531
509
reason ?: any ,
532
510
) : Promise < void > {
533
- if ( isError ) this . logger . info ( `send closed with error ${ reason . message } ` ) ;
511
+ if ( isError ) this . logger . debug ( `send closed with error ${ reason . message } ` ) ;
534
512
// Further closes are NOPs
535
513
if ( this . _sendClosed ) return ;
536
- this . logger . info ( `Close Send` ) ;
514
+ this . logger . debug ( `Close Send` ) ;
537
515
// Indicate that the sending side is closed
538
516
this . _sendClosed = true ;
539
517
// If the QUIC stream is already closed
@@ -580,39 +558,6 @@ class QUICStream
580
558
}
581
559
return null ;
582
560
}
583
-
584
- static checkStreamStates (
585
- conn : Connection ,
586
- streamId : number ,
587
- message : string ,
588
- logger : Logger ,
589
- ) {
590
- const fin = conn . streamFinished ( streamId ) ;
591
- const read = conn . streamReadable ( streamId ) ;
592
- let write : boolean | string ;
593
- try {
594
- write = conn . streamWritable ( streamId , 0 ) ;
595
- } catch ( e ) {
596
- write = e . message ;
597
- }
598
- let cap : number | string ;
599
- try {
600
- cap = conn . streamCapacity ( streamId ) ;
601
- } catch ( e ) {
602
- cap = e . message ;
603
- }
604
- let readIter = false ;
605
- for ( const id of conn . readable ( ) ) {
606
- if ( streamId === id ) readIter = true ;
607
- }
608
- let writeIter = false ;
609
- for ( const id of conn . writable ( ) ) {
610
- if ( streamId === id ) writeIter = true ;
611
- }
612
- logger . info (
613
- `Stream states (${ message } ) iterRW(${ readIter } , ${ writeIter } ),finished(${ fin } ), read(${ read } ), write(${ write } ), capacity(${ cap } )` ,
614
- ) ;
615
- }
616
561
}
617
562
618
563
export default QUICStream ;
0 commit comments