Skip to content

Commit 0e0b64d

Browse files
author
Geoffroy Couprie
authored
patch async-compression to compress responses in streaming (#1604)
Fix #1572 async-compression is used in tower-http's CompressionLayer. Inside the AsyncRead based compression code, if the underlying stream returns Poll::Pending, it will be returned directly, while in the case of deferred responses, the next one might come way later, so we want to send whatever data we have available right now. We will have to switch to an AsyncWrite interface instead, which will be more flexible, but considering the timing of the release, this patch will hold for now. This uses the code from Nullus157/async-compression#155
1 parent 1fde257 commit 0e0b64d

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

Cargo.lock

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+8
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,11 @@ members = [
3232
# debug = false
3333
strip = "debuginfo"
3434
incremental = false
35+
36+
# Temporary patch to async-compression
37+
# It is used by tower-http's CompressionLayer. The compression code was not handling
38+
# the Poll::Pending result from the underlying stream, so it was accumulating the
39+
# entire compressed response in memory before sending it, which creates issues with
40+
# deferred responses getting received too late
41+
[patch.crates-io]
42+
async-compression = { git = 'https://github.com/geal/async-compression', branch = 'encoder-flush' }

NEXT_CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ next chunk to see the delimiter.
192192

193193
By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/1596
194194

195+
### Patch async-compression to compress responses in streaming ([PR #1604](https://github.com/apollographql/router/issues/1604))
196+
197+
async-compression is a dependency used for response compression. Its implementation accumulates the entire compressed response
198+
in memory before sending it, which creates problems for deferred responses, where we want the responses to come as soon as
199+
possible, and not all at once after a while.
200+
201+
By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/1604
202+
195203
## 🛠 Maintenance
196204

197205
### Depend on published `router-bridge` ([PR #1613](https://github.com/apollographql/router/issues/1613))

0 commit comments

Comments
 (0)