Skip to content

Commit

Permalink
patch async-compression to compress responses in streaming (#1604)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Geal committed Aug 26, 2022
1 parent 1fde257 commit 0e0b64d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ members = [
# debug = false
strip = "debuginfo"
incremental = false

# Temporary patch to async-compression
# It is used by tower-http's CompressionLayer. The compression code was not handling
# the Poll::Pending result from the underlying stream, so it was accumulating the
# entire compressed response in memory before sending it, which creates issues with
# deferred responses getting received too late
[patch.crates-io]
async-compression = { git = 'https://github.com/geal/async-compression', branch = 'encoder-flush' }
8 changes: 8 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ next chunk to see the delimiter.

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

### Patch async-compression to compress responses in streaming ([PR #1604](https://github.com/apollographql/router/issues/1604))

async-compression is a dependency used for response compression. Its implementation accumulates the entire compressed response
in memory before sending it, which creates problems for deferred responses, where we want the responses to come as soon as
possible, and not all at once after a while.

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

## 🛠 Maintenance

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

0 comments on commit 0e0b64d

Please sign in to comment.