rust-eventsource-client icon indicating copy to clipboard operation
rust-eventsource-client copied to clipboard

Infinite loop in rare conditions

Open spolu opened this issue 2 years ago • 8 comments

Here's a piece of code that uses event-source and leads in rare cases to an infinite loop: https://github.com/dust-tt/dust/blob/fbced883d7e62d8c69624c5d19e48dbe9d8e9708/core/src/providers/openai.rs#L189-L332

I was able to profile the program and got the following flamegraph. Looks like it's looping inside of eventsource-client? test

spolu avatar Feb 15 '23 10:02 spolu

Maybe it's caused by the fact that I have reconnects deactivated? https://github.com/launchdarkly/rust-eventsource-client/blob/main/eventsource-client/src/client.rs#L469-L475

spolu avatar Feb 15 '23 10:02 spolu

I'm sorry you are experiencing this issue!

In both the event source library, and in the example you provided, there are several bits of logging information which might help us uncover some more insight into when this is happening.

Can you please provide some sample logging output when this issue occurs?

keelerm84 avatar Feb 15 '23 15:02 keelerm84

No logging at all (no HERE, no UNEXPECTED). Which is mind boggling to me :/

How can I activate the lib debug logging?

spolu avatar Feb 15 '23 19:02 spolu

We use the log crate for logging. So you just need to initialize some logger that is compatible with that (e.g. env_logger) and then run your app with the appropriate RUST_LOG=evensource=trace level.

keelerm84 avatar Feb 15 '23 20:02 keelerm84

Will do that and report, hopefully stumbling on it again quickly

spolu avatar Feb 15 '23 20:02 spolu

(Depends a lot on health state of OpenAI API 😅)

spolu avatar Feb 15 '23 20:02 spolu

Hi @spolu, just checking in, were you able to gather any logging for this issue?

cwaldren-ld avatar Mar 03 '23 22:03 cwaldren-ld

The issue vanished by adding ReconnectOptions: https://github.com/dust-tt/dust/blob/main/core/src/providers/openai.rs#L241-L246

That does not resolve the whole problem. But at least that's an interesting hint.

spolu avatar Mar 05 '23 12:03 spolu

Closing out of inactivty

spolu avatar May 31 '24 15:05 spolu