fanout / django-eventstream

Server-Sent Events for Django
MIT License
638 stars 84 forks source link

Overwrite request last id for avoiding infinite loop #83

Closed Iftimie closed 2 years ago

Iftimie commented 2 years ago

Summary:

Explanation: When the frontend sends lastEventId like ReconnectingEventSource('/events/?channel=testchannel', {lastEventId: 'testchannel:0'}) or like this ReconnectingEventSource('/events/?channel=testchannel&lastEventId=testchannel:0')

the backend can get in an infinite loop.

Thus, overwriting the last_id in the same request object solves the problem

jkarneges commented 2 years ago

Thanks for this!

It looks like the two commits aren't quite related. The one that fixes the infinite loop seems legitimate, and I'm willing to merge it. However, I'm skeptical about the one that changes the storage behavior. Can you remove the latter (perhaps put it in a separate PR) so that I can merge this PR to only fix the infinite loop?

Iftimie commented 2 years ago

Hi! Sorry for the second commit. That was a mistake.