compression icon indicating copy to clipboard operation
compression copied to clipboard

On-demand flush

Open mfulton26 opened this issue 1 year ago • 3 comments
trafficstars

I have a suspicion that using text/event-stream with CompressiomStream could cause delays in delivering events to consumers but I'm not sure that's true or not. It seems to me that after enqueing some event(s)/chunk(s) that the compression stream could be in a waiting state for more bytes to compress before it enques corresponding compressed chunk(s).

Is some flush() method needed in order to reliably send a compressed stream of events and to guarantee that individual events are not delayed?

Demo: https://dash.deno.com/playground/event-stream-example

mfulton26 avatar Apr 08 '24 10:04 mfulton26

Yes. See also https://github.com/WICG/compression/issues/22.

ricea avatar Apr 09 '24 07:04 ricea

Is there an expected flushing strategy for browsers to implement today for CompressionStream or is it undefined? If it is already "always" then I'm set for my current use cases but I'm guessing that is not the case. I wonder if there is an expected flushing strategy with which I might be able to find a workaround. Thank you.

mfulton26 avatar Apr 11 '24 12:04 mfulton26

Sorry, it is implementation-dependant at the moment. I don't think there's a good workaround. We should make it a priority to fix #22 once the migration from WICG to WHATWG is done.

ricea avatar Apr 12 '24 13:04 ricea