-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Hey there,
First of all thank you for creating these many small modules. Very handy! ❤️
I've been working on replacing intesso/connect-livereload with fgnass/instant and noticed it uses this module to send out the events. One of the things that drove me to using instant is the seamless transition from "dev mode" to "prod mode" from a consumer perspective (meaning I don't have to fork my code to inject different things in dev vs prod as it makes for a brittle setup). So thank you for that! 🍻
While working with server sent events in the past, I experienced issues with gzipped responses (using expressjs/compression) and had to disable compression for certain routes… not ideal. There is, in fact, a section on expressjs/compression#server-sent-events that describes how to deal with compressed responses and SSE. It ends up being specific to that library, given that library is the one that adds the .flush function to the response object. The intesso/connect-livereload library has an option, but I'm not sure if it is suitable for this scenario…
I haven't taken the time to attempt any fixes yet, so I though I'd file an issue here first and was wondering if you have any thoughts. Cheers!
EDIT: I just realized I didn't explain the actual issue… 😄 What happens is that, by using gzip compression (or any compression, I'd say), the events sent by the server don't reach the clients. To quote expressjs/compression#server-sent-events:
Because of the nature of compression this module does not work out of the box with server-sent events. To compress content, a window of the output needs to be buffered up in order to get good compression. Typically when using server-sent events, there are certain block of data that need to reach the client.