superfly / litefs

FUSE-based file system for replicating SQLite databases across a cluster of machines
Apache License 2.0
3.76k stars 89 forks source link

Continuously flush proxy response #415

Closed benbjohnson closed 8 months ago

benbjohnson commented 8 months ago

Currently, the proxy server uses io.Copy() for the response which means the response is only flushed at the end. This won't work for streaming responses. Instead, it should manually implement a copy and call http.Flusher.Flush() after receiving each section of bytes.

Code: https://github.com/superfly/litefs/blob/117c6524594a5ecf0a126b56da7b1ed35090fc00/http/proxy_server.go#L325-L330

See also: https://community.fly.io/t/response-buffering-inconsistent-results-when-reading-from-http-with-text-event-stream-mime-type/8430/17

kentcdodds commented 8 months ago

This will be really nice to have fixed! Thank you 👏