You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When making streaming responses and activating middleware::Compress, the compression seems to buffer content indefinitely, without ever flushing the streaming data when it's small enough.
When visiting http://localhost:8080/compressed/ the page stays blank for five seconds, then displays This content appears immediately and This content appears after 5 seconds at the same time.
Possible Solution
The compression middleware should flush the writer object after a few milliseconds without new input data, to avoid indefinitely retaining data in memory on the server when it could actually already be rendered on the client.
It's possible to retain data in memory for a few milliseconds to ensure good compression ratios, but actix shouldn't keep streaming data in memory for multiple seconds.
Context
We are trying to integrate easy native loading spinners without javascript in SQLPage
Your Environment
Actix Web Version: 4.8.0
The text was updated successfully, but these errors were encountered:
With non-compressed streams it works because each Bytes object is assumed to be a chunk of data that should be flushed eagerly. However with compression it isn't so simple. If a chunk compresses very well it may be desirable to not flush a tiny buffer and send a small packet over the wire. However this is clearly suboptimal in cases like this where there is no next chunk soon to be available.
It would be nice to be able to do both:
If the next chunk is not ready flush the current chunk.
Provide an API for explicit flushing.
However this may require a pretty substantial change to how Body looks.
Workaround
For my app only a small number of endpoints rely on streaming chunked responses so I disabled compression on these routes by stripping the Accept-Encoding header. Ugly, but it lets me get the benefits of compression on most of my routes without throwing away streaming responses.
Initially reported sqlpage/SQLPage#435
When making streaming responses and activating
middleware::Compress
, the compression seems to buffer content indefinitely, without ever flushing the streaming data when it's small enough.Here is an example demonstrating the problem
Expected Behavior
This content appears immediately
immediateley, and then after 5 secondsThis content appears after 5 seconds
Current Behavior
This content appears immediately
andThis content appears after 5 seconds
at the same time.Possible Solution
The compression middleware should flush the writer object after a few milliseconds without new input data, to avoid indefinitely retaining data in memory on the server when it could actually already be rendered on the client.
It's possible to retain data in memory for a few milliseconds to ensure good compression ratios, but actix shouldn't keep streaming data in memory for multiple seconds.
Context
We are trying to integrate easy native loading spinners without javascript in SQLPage
Your Environment
The text was updated successfully, but these errors were encountered: