diff --git a/packages/grpc-js/README.md b/packages/grpc-js/README.md index dfe805021..42d579854 100644 --- a/packages/grpc-js/README.md +++ b/packages/grpc-js/README.md @@ -70,6 +70,7 @@ Many channel arguments supported in `grpc` are not supported in `@grpc/grpc-js`. - `grpc-node.max_session_memory` - `grpc-node.tls_enable_trace` - `grpc-node.retry_max_attempts_limit` + - `grpc-node.http2_initial_window_size` - `channelOverride` - `channelFactoryOverride` diff --git a/packages/grpc-js/src/channel-options.ts b/packages/grpc-js/src/channel-options.ts index e605d3f76..04c26b03a 100644 --- a/packages/grpc-js/src/channel-options.ts +++ b/packages/grpc-js/src/channel-options.ts @@ -64,6 +64,7 @@ export interface ChannelOptions { 'grpc-node.tls_enable_trace'?: number; 'grpc.lb.ring_hash.ring_size_cap'?: number; 'grpc-node.retry_max_attempts_limit'?: number; + 'grpc-node.http2_initial_window_size'?: number; // eslint-disable-next-line @typescript-eslint/no-explicit-any [key: string]: any; } @@ -101,6 +102,7 @@ export const recognizedOptions = { 'grpc-node.tls_enable_trace': true, 'grpc.lb.ring_hash.ring_size_cap': true, 'grpc-node.retry_max_attempts_limit': true, + 'grpc-node.http2_initial_window_size': true, }; export function channelOptionsEqual( diff --git a/packages/grpc-js/src/transport.ts b/packages/grpc-js/src/transport.ts index 97c2ffbcd..bb9257df5 100644 --- a/packages/grpc-js/src/transport.ts +++ b/packages/grpc-js/src/transport.ts @@ -672,6 +672,11 @@ export class Http2SubchannelConnector implements SubchannelConnector { const session = http2.connect(`http://${targetPath}`, { createConnection: (authority, option) => { return underlyingConnection; + }, + settings: { + initialWindowSize: + options['grpc-node.http2_initial_window_size'] || + http2.getDefaultSettings().initialWindowSize, } }); this.session = session;