CompressionLayer does not produce compressed data in streaming #292
Labels
C-bug
Category: This is a bug.
E-hard
Call for participation: Experience needed to fix: Hard / a lot
E-help-wanted
Call for participation: Help is requested to fix this issue.
Bug Report
Version
0.3.4
Platform
Linux 5.18.10-76051810-generic, but probably not relevant
Crates
tower-http, async-compression
Description
We noticed in apollographql/router#1572 that the
CompressionLayer
waits until the entire response body is compressed to send it to the client. This is due to theEncoder
behaviour in async-compression: Nullus157/async-compression#154.How we saw that result:
Stream
ofBytes
that is wrapped in an axumStreamBody
The issue comes from this part:
https://github.com/Nemo157/async-compression/blob/ada65c660bcea83dc6a0c3d6149e5fbcd039f739/src/tokio/bufread/generic/encoder.rs#L63-L74
When the underlying stream returns
Poll::Pending
,ready!
will return it directly, so no data will be produced. I patched this in our router to produce data whenever we see aPending
, but that's not a proper solution.Instead, the
CompressionLayer
should be able to direct theEncoder
to produce data depending on conditions like how much data could be produced, or how long since the last chunk was sentThe text was updated successfully, but these errors were encountered: