node-restify icon indicating copy to clipboard operation
node-restify copied to clipboard

Gzip plugin prevents text/event-stream from working

Open jameswomack opened this issue 9 years ago • 7 comments

I have to call

      res.handledGzip && res.handledGzip();
      res.removeHeader('Content-Encoding');

in my SSE plugin to bypass the Gzip plugin—otherwise EventSource fails.

The solution would involve adding support for keep alive connection in the Gzip plugin.

jameswomack avatar Jun 02 '15 23:06 jameswomack

Interesting. Can you please give me some sample code I can run to repro?

yunong avatar Jun 03 '15 00:06 yunong

I've created an example in jameswomack/restify-eventsource.

The commit that shows what needs to be bypassed is 26ac2e8ae3ada96743f0d15a8dc4582d035e4c69

The example file is @ https://github.com/jameswomack/restify-eventsource/blob/restification/example.js

jameswomack avatar Jun 05 '15 22:06 jameswomack

Marking as unconfirmed until a maintainer is able to reproduce. We appreciate you creating a repro case!

retrohacker avatar Apr 29 '17 12:04 retrohacker

@retrohacker thanks

jameswomack avatar May 04 '17 21:05 jameswomack

SSE looks super slick :smile:

Is this module being used anywhere, and it it stable? Would love to link to it from the website.

The repro case looks like it conflates a lot of the SSE logic with gzip breaking keep-alive connections, I'm going to attempt to make a smaller repro case here soon. Is it fair to say that the core of this issue is our gzip plugin not supporting keep-alive sessions?

retrohacker avatar May 08 '17 14:05 retrohacker

Is it fair to say that the core of this issue is our gzip plugin not supporting keep-alive sessions?

@retrohacker yes I think you can say that

Is this module being used anywhere, and it it stable? Would love to link to it from the website.

I've only used it on smaller projects and nothing in the past 6 months. It worked well for me, but I can't speak to it beyond that 😄

jameswomack avatar May 18 '17 21:05 jameswomack

I can confirm I am seeing the same behavior and also confirm that the workaround works but is not ideal since we lose compression. The alternative workaround is to wrap the gzip plugin to conditionalize when it gets invoked based on the accept-header.

sppatel avatar Nov 01 '19 11:11 sppatel