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 {
719719 settings : {
720720 initialWindowSize :
721721 options [ 'grpc-node.flow_control_window' ] ??
722- http2 . getDefaultSettings ( ) . initialWindowSize ,
722+ http2 . getDefaultSettings ( ) . initialWindowSize ?? 65535 ,
723723 }
724724 } ) ;
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+
725732 this . session = session ;
726733 let errorMessage = 'Failed to connect' ;
727734 let reportedError = false ;
728735 session . unref ( ) ;
729736 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+
730749 session . removeAllListeners ( ) ;
731750 secureConnectResult . socket . removeListener ( 'close' , closeHandler ) ;
732751 secureConnectResult . socket . removeListener ( 'error' , errorHandler ) ;
You can’t perform that action at this time.
0 commit comments