Fix large gRPC response truncation

This commit is contained in:
Chris Eager authored and ravi-signal committed 2026-09-23 13:32:17 -05:00
1 parent 9bbd04afaa
commit 3f7012dba4
1 file changed
+15 -1
@@ -57,12 +57,26 @@ public class H2FrameProxyHandler extends ChannelInboundHandlerAdapter {
"proxy", proxyNameTag,
BACKEND_TAG_NAME, backendNameTag)
.increment();
ctx.channel().config().setAutoRead(peerStream.isWritable());
setAutoRead(ctx.channel(), peerStream.isWritable());
super.channelWritabilityChanged(peerCtx);
}
});
}
/// Set auto-read on `channel`, ensuring the call happens on the channel’s event loop.
///
/// [io.netty.channel.ChannelConfig#setAutoRead] implementations appear to handle calls from outside the event
/// loop, but without conservatively ensuring the call happens on the event loop, proxied responses are sometimes
/// truncated.
private static void setAutoRead(final Channel channel, final boolean autoRead) {
if (!channel.eventLoop().inEventLoop()) {
channel.eventLoop().execute(() -> setAutoRead(channel, autoRead));
return;
}
channel.config().setAutoRead(autoRead);
}
@Override
public void channelRead(final ChannelHandlerContext ctx, final Object msg) {
logger.trace("Received frame {}", msg);