mirror of https://github.com/grpc/grpc-node.git
fix(http2): move WINDOW_UPDATE handling to remoteSettings event
This commit is contained in:
parent
b69bcad1bb
commit
0e09b9cd59
|
@ -723,28 +723,29 @@ export class Http2SubchannelConnector implements SubchannelConnector {
|
|||
}
|
||||
});
|
||||
|
||||
// Send WINDOW_UPDATE now to avoid 65 KB start-window stall.
|
||||
// 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;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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