sseclient icon indicating copy to clipboard operation
sseclient copied to clipboard

0.0.24 doesn't process large events

Open Samwalton9 opened this issue 6 years ago • 10 comments

I'm not sure exactly where the problem is here, but I just had to downgrade to 0.0.22 (as the last version I know was working, not sure if the issue is in .23 or .24). Events that were particularly large seemed to not be coming through when looping over an EventSource feed. I'll see if I get some time to dig into this a bit further and provide more information soon.

Samwalton9 avatar Jul 17 '19 14:07 Samwalton9

If you can provide a test that reproduces the failure, that would be awesome.

btubbs avatar Aug 03 '19 07:08 btubbs

Are you using chunked encoding by any chance? If so, I believe that this may be a duplicate of #28. Can you give https://github.com/mutantmonkey/sseclient/tree/disable_short_reads_when_chunked a try and see whether or not it fixes the issue? If so, I'll go ahead and open a PR.

mutantmonkey avatar Aug 06 '19 02:08 mutantmonkey

@Samwalton9 ^

TheSandDoctor avatar Feb 27 '20 18:02 TheSandDoctor

Hi, I had this issue also with version 0.0.26. It seemed to be resolved when I downgraded to 0.0.22. I don't think I can paste the data here, but to provide some context the json event that it's trying to read is around 1500 lines (500KB).

adeel-ansari avatar Jun 24 '20 18:06 adeel-ansari

@mutantmonkey I was having the problem and it was related to chunked transfer. Your code definitely works differently, compared to the latest code here in the repo. However, it doesn't seem to emit the events when the occur. For example, sometime I am getting several ping event at once, even though they usually occur with a regular frequency.

docbobo avatar Nov 14 '20 13:11 docbobo

@docbobo Thanks for testing. Yeah, that would be the expected behavior as events won't be emitted until the buffer fills up. That's the problem that can be fixed by using short reads, but my understanding is that currently using chunked encoding results in errors when processing events because the chunk size is also included in the event data (see #28). The way to fix this would be to implement short reads for chunked encoding as well instead of falling back to disable them.

What's the issue you see with the current code in master?

mutantmonkey avatar Nov 15 '20 19:11 mutantmonkey

@mutantmonkey in my case, it just completely breaks the event. No way to parse it into JSON, with the chunking not being transparently handled.

docbobo avatar Nov 23 '20 11:11 docbobo

The problem with large event data is in the _event_complete method. For every new data chunk it applies a regular expression to all buffered data, resulting in a quadratic execution time.

⚠️This can be easily exploided in a Denial of Service attack.

decatur avatar Jan 08 '21 10:01 decatur