Skip to content

Conversation

@gavinbunney
Copy link
Collaborator

@gavinbunney gavinbunney commented Oct 8, 2025

If a client request is responded by an origin immediately whilst the client is still sending the request (i.e. the origin has enough details in the headers to respond) then warnings are logged.

This PR silences those warnings for cases when the client does not have a body but the origin still responded before the client channel LastContent was sent through the pipeline.

Example log:

Writing response to client channel before have received the LastContent of request! 
uri=https://example.org, method=get, clientip=192.168.0.1, Channel: [id: 0xfoo, L:/... - R:...], active=true, open=true, ...

@gavinbunney gavinbunney marked this pull request as ready for review October 8, 2025 20:12
&& !shouldAllowPreemptiveResponse(channel)
&& zuulResponse.getInboundRequest().hasBody()) {
responseBeforeReceivedLastContentCounter.increment();
logger.warn(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this warning useful overall?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be a signal of a misbehaving client or origin; will be interesting to see how it behaves in prod given the metric should reduce/provide insight into the cases when it does legitimately happen

}

@ParameterizedTest
@ValueSource(booleans = {false, true})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

if (hasBodyChunk) {
request.bufferBodyContents(new io.netty.handler.codec.http.DefaultHttpContent(
Unpooled.copiedBuffer("body", java.nio.charset.StandardCharsets.UTF_8)));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember if zuul-core tests have leak detection asserts or not, but can you release this if it isn't being released somewhere else already?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call - added a dispose call

@gavinbunney gavinbunney merged commit f62955d into master Oct 8, 2025
4 checks passed
@gavinbunney gavinbunney deleted the gavin/client-request branch October 8, 2025 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants