File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -719,14 +719,33 @@ export class Http2SubchannelConnector implements SubchannelConnector {
719
719
settings : {
720
720
initialWindowSize :
721
721
options [ 'grpc-node.flow_control_window' ] ??
722
- http2 . getDefaultSettings ( ) . initialWindowSize ,
722
+ http2 . getDefaultSettings ( ) . initialWindowSize ?? 65535 ,
723
723
}
724
724
} ) ;
725
+
726
+ // Prepare window size configuration for remoteSettings handler
727
+ const defaultWin = http2 . getDefaultSettings ( ) . initialWindowSize ?? 65535 ; // 65 535 B
728
+ const connWin = options [
729
+ 'grpc-node.flow_control_window'
730
+ ] as number | undefined ;
731
+
725
732
this . session = session ;
726
733
let errorMessage = 'Failed to connect' ;
727
734
let reportedError = false ;
728
735
session . unref ( ) ;
729
736
session . once ( 'remoteSettings' , ( ) => {
737
+ // Send WINDOW_UPDATE now to avoid 65 KB start-window stall.
738
+ if ( connWin && connWin > defaultWin ) {
739
+ try {
740
+ // Node ≥ 14.18
741
+ ( session as any ) . setLocalWindowSize ( connWin ) ;
742
+ } catch {
743
+ // Older Node: bump by the delta
744
+ const delta = connWin - ( session . state . localWindowSize ?? defaultWin ) ;
745
+ if ( delta > 0 ) ( session as any ) . incrementWindowSize ( delta ) ;
746
+ }
747
+ }
748
+
730
749
session . removeAllListeners ( ) ;
731
750
secureConnectResult . socket . removeListener ( 'close' , closeHandler ) ;
732
751
secureConnectResult . socket . removeListener ( 'error' , errorHandler ) ;
You can’t perform that action at this time.
0 commit comments