fix(cloudfront): release origin connections when viewers disconnect (#5564)

This commit is contained in:
Abhigya authored and GitHub committed 2026-10-13 09:11:50 -04:00
1 parent 66b2ec05e9
commit ee229af975
2 files changed
+65

No files matched your search

@@ -34,6 +34,7 @@ import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.StreamingOutput;
import jakarta.ws.rs.core.UriInfo;
import org.jboss.logging.Logger;
import org.jboss.resteasy.reactive.server.core.CurrentRequestManager;
import java.io.IOException;
import java.io.InputStream;
@@ -1022,6 +1023,9 @@ public class CloudFrontServingController {
}
}
if (includeBody && origin.stream() != null) {
// A disconnected viewer can skip StreamingOutput entirely, so its finally block
// alone cannot release the origin connection.
CurrentRequestManager.get().registerCompletionCallback(ignored -> origin.closeStream());
InputStream body = origin.stream();
StreamingOutput entity = output -> {
try (InputStream in = body) {