Skip to content

Commit

Permalink
fix: allow configurable http2 initial window size. fixes grpc#2429
Browse files Browse the repository at this point in the history
  • Loading branch information
rickihastings committed Dec 6, 2024
1 parent 8f08bbe commit d08318d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/grpc-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
2 changes: 2 additions & 0 deletions packages/grpc-js/src/channel-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions packages/grpc-js/src/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d08318d

Please sign in to comment.