Repository navigation
Description
Describe the bug
When using S3AsyncClient with NettyNioAsyncHttpClient and AsyncResponseTransformer.toPublisher(), a response body truncated by a normal TCP close (FIN) can leave the body subscriber waiting indefinitely.
The SDK detects a Content-Length mismatch but does not deliver onError() to the body subscriber. Consequently, application-level failure handling and cleanup that depend on body completion never execute.
Downstream report: AutoMQ/automq#3664
Expected behavior
When the connection closes before the declared response body has been received, the body subscriber should receive onError(Throwable).
This report concerns missing error notification, not automatic retries.
Bug flow
Source inspected: master at commit 0d74c169df9c7f2a2d4d59cdcf7732472d9809e6.
toPublisher() future completes when the body publisher becomes available
→ application subscribes and requests body data
→ server sends fewer bytes than Content-Length, then closes with FIN
→ HandlerPublisher.channelInactive() invokes complete()
→ PublisherAdapter.onComplete() detects the length mismatch
→ IOException is reported to the response handler, but not the subscriber
→ subscriber receives neither onComplete() nor onError()
The key code is in ResponseHandler.PublisherAdapter.onComplete():
try {
validateResponseContentLength(channelContext);
// Notify subscriber.onComplete() and finalize the response.
...
} catch (IOException e) {
notifyError(e);
// Close and release the channel.
...
}The catch block never calls subscriber.onError(e). notifyError() only notifies the HTTP response handler and completes the HTTP execute future exceptionally.
For PublisherAsyncResponseTransformer, that error notification cannot reach the body consumer:
public void onStream(SdkPublisher<ByteBuffer> publisher) {
future.complete(new ResponsePublisher<>(response, publisher, timeout));
}
public void exceptionOccurred(Throwable error) {
future.completeExceptionally(error); // Already completed by onStream().
}By contrast, PublisherAdapter.onError() explicitly calls subscriber.onError(), consistent with the downstream observation that TCP RST and read timeout correctly report errors.
Reproduction steps
- Configure a Netty-backed
S3AsyncClientto use a local HTTP server. - Issue a ranged
getObject()withAsyncResponseTransformer.toPublisher(). - Subscribe to the returned publisher and request body data.
- Respond with HTTP
206, valid range headers, andContent-Length: N. - Send a non-empty body shorter than
N, then close the connection normally with FIN. - Observe that the subscriber receives neither
onComplete()noronError().
Controls reported downstream:
- TCP RST during body transfer: error notification is received.
- Connection left idle until Netty read timeout: error notification is received.
Verification status
The downstream reporter observed this behavior with SDK 2.26.10. We inspected master at the commit above and found the missing subscriber error-notification path. We have not independently run the network reproducer on master.
Suggested fix
Deliver content-length validation failures to the body subscriber through onError(), preserving exactly-once terminal signaling and channel cleanup.
Note that PublisherAdapter.onComplete() sets isDone before validation, so simply calling the existing onError() method from the catch block would return without notifying the subscriber.
Environment
Downstream report: Linux / Kubernetes, Netty NIO HTTP client.
Activity
[-]Netty: truncated response followed by TCP FIN leaves toPublisher() subscriber hanging[/-][+]S3: truncated response followed by TCP FIN leaves toPublisher() subscriber hanging[/+][-]S3: truncated response followed by TCP FIN leaves toPublisher() subscriber hanging[/-][+]BUG(S3): truncated response followed by TCP FIN leaves toPublisher() subscriber hanging[/+]debora-ito commentedon Oct 20, 2026
Hi @superhx thank you for reaching out.
I see you also reported a related issue in #6949, I apologize it didn't get a reply yet, it probably went unnoticed because they don't have the labels that are applied when the Github new issue template is used.
Anyway, we are taking a look.
feat(s3): use CRT HTTP transport by default (#3682)
feat(s3): use CRT HTTP transport by default (1.8) (#3683)
huong8373tt-beep commentedon Oct 30, 2026
I am preparing a focused fix for the missing terminal
onErrornotification when streamed response content-length validation fails, with a regression test in the Netty publisher adapter path.Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.
huong8373tt-beep commentedon Oct 30, 2026
Opened #7499 with the focused Netty publisher-adapter fix and regression coverage. Local verification completed with the Netty dependency reactor build and
PublisherAdapterTest(5 tests passed).Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.