mirror of https://github.com/grpc/grpc-node.git
Merge pull request #2971 from KoenRijpstra/fix/early-connection-window-update
Fix: send connection-level WINDOW_UPDATE at session start
This commit is contained in:
commit
6573a0ebe4
|
@ -719,14 +719,33 @@ export class Http2SubchannelConnector implements SubchannelConnector {
|
|||
settings: {
|
||||
initialWindowSize:
|
||||
options['grpc-node.flow_control_window'] ??
|
||||
http2.getDefaultSettings().initialWindowSize,
|
||||
http2.getDefaultSettings().initialWindowSize ?? 65535,
|
||||
}
|
||||
});
|
||||
|
||||
// Prepare window size configuration for remoteSettings handler
|
||||
const defaultWin = http2.getDefaultSettings().initialWindowSize ?? 65535; // 65 535 B
|
||||
const connWin = options[
|
||||
'grpc-node.flow_control_window'
|
||||
] as number | undefined;
|
||||
|
||||
this.session = session;
|
||||
let errorMessage = 'Failed to connect';
|
||||
let reportedError = false;
|
||||
session.unref();
|
||||
session.once('remoteSettings', () => {
|
||||
// Send WINDOW_UPDATE now to avoid 65 KB start-window stall.
|
||||
if (connWin && connWin > defaultWin) {
|
||||
try {
|
||||
// Node ≥ 14.18
|
||||
(session as any).setLocalWindowSize(connWin);
|
||||
} catch {
|
||||
// Older Node: bump by the delta
|
||||
const delta = connWin - (session.state.localWindowSize ?? defaultWin);
|
||||
if (delta > 0) (session as any).incrementWindowSize(delta);
|
||||
}
|
||||
}
|
||||
|
||||
session.removeAllListeners();
|
||||
secureConnectResult.socket.removeListener('close', closeHandler);
|
||||
secureConnectResult.socket.removeListener('error', errorHandler);
|
||||
|
|
Loading…
Reference in New Issue