Skip to content

Conversation

@idelpivnitskiy
Copy link
Member

Motivation:

When gRPC client receives a response, it first validates that it's formed according to gRPC specification. If any headers or trailers are missing, validateResponseAndGetPayload will throw an exception. In this case, we leak undrained response payload body.

Modifications:

  1. Try catch logic of validateResponseAndGetPayload, subscribe and cancel response message body in case of unexpected exceptions.
  2. Enhance ProtocolCompatibilityTest to validate we never leak responses across all tests.

Result:

Responses are properly drained even when we receive malformed responses.

Motivation:

When gRPC client receives a response, it first validates that it's
formed according to gRPC specification. If any headers or trailers are
missing, `validateResponseAndGetPayload` will throw an exception. In
this case, we leak undrained response payload body.

Modifications:

1. Try catch logic of `validateResponseAndGetPayload`, subscribe and
cancel response message body in case of unexpected exceptions.
2. Enhance `ProtocolCompatibilityTest` to validate we never leak
responses across all tests.

Result:

Responses are properly drained even when we receive malformed responses.
@idelpivnitskiy idelpivnitskiy merged commit 25193c2 into apple:main Oct 29, 2025
11 checks passed
@idelpivnitskiy idelpivnitskiy deleted the leak branch October 29, 2025 20:39
lawrencewang49 pushed a commit to lawrencewang49/servicetalk that referenced this pull request Oct 30, 2025
…ed (apple#3354)

Motivation:

When gRPC client receives a response, it first validates that it's
formed according to gRPC specification. If any headers or trailers are
missing, `validateResponseAndGetPayload` will throw an exception. In
this case, we leak undrained response payload body.

Modifications:

1. Try catch logic of `validateResponseAndGetPayload`, subscribe and
cancel response message body in case of unexpected exceptions.
2. Enhance `ProtocolCompatibilityTest` to validate we never leak
responses across all tests.

Result:

Responses are properly drained even when we receive malformed responses.
lawrencewang49 pushed a commit to lawrencewang49/servicetalk that referenced this pull request Oct 30, 2025
…ed (apple#3354)

Motivation:

When gRPC client receives a response, it first validates that it's
formed according to gRPC specification. If any headers or trailers are
missing, `validateResponseAndGetPayload` will throw an exception. In
this case, we leak undrained response payload body.

Modifications:

1. Try catch logic of `validateResponseAndGetPayload`, subscribe and
cancel response message body in case of unexpected exceptions.
2. Enhance `ProtocolCompatibilityTest` to validate we never leak
responses across all tests.

Result:

Responses are properly drained even when we receive malformed responses.
idelpivnitskiy added a commit to idelpivnitskiy/servicetalk that referenced this pull request Oct 31, 2025
Motivation:

apple#3354 introduced `ProtocolCompatibilityTest.ResponseLeakValidator`.
However, the test thread that asserts `pendingRequests` counter can race
with `GrpcUtils.validateResponseAndGetPayload` logic for Trailers-Only
response draining that executes inside `afterOnError` callback.

Modifications:

- Use `CountDownLatch` to ensure all new requests were terminated.

Result:

Fixes apple#3356
idelpivnitskiy added a commit that referenced this pull request Oct 31, 2025
Motivation:

#3354 introduced `ProtocolCompatibilityTest.ResponseLeakValidator`.
However, the test thread that asserts `pendingRequests` counter can race
with `GrpcUtils.validateResponseAndGetPayload` logic for Trailers-Only
response draining that executes inside `afterOnError` callback.

Modifications:

- Use `CountDownLatch` to ensure all new requests were terminated.

Result:

Fixes #3356
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.

2 participants