First of all, thanks @jordanbyron for the great work you've done! 👏
I noticed a strange issue on my end. Long story short - the same MessageEvent is getting dispatched via the EventSource over and over again, even though the back-end is not emitting a new message.
Here's the MessageEvent which gets dispatched:
{
data: "large stringified object with `creationDate` (timestamp) which the server sends"
lastEventId: ""
origin: undefined
}
I'm sure that my back-end is not emitting a new message because I also have a web interface where I can test, wired up with the EventSource Web API, where the issue doesn't occur. Moreover the creationDate timestamp in the MessageEvents data I'm receiving from my server and all the other params are absolutely the same.
On my end, this is causing performance issues, because it triggers my sseSource.addEventListener logic I have over and over again every minute or so (there is around 1 min delay until all of the same events get dispatched again, so strange?).
My implementation is quite straight-forward, nothing special I think:
const sseSource = new EventSource(mySseUrl, {
headers: { Authorization: 'Bearer ' + accessToken },
withCredentials: false,
});
sseSource.addEventListener('some-event', (response) => console.log(response));
I tend to think that the issue is related to the react-native-event-source implementation, please let me know if you've experienced the same thing? Or if I should search for a problem elsewhere in my application / server implementation?
Edit: Expo SDK v35 (also reproducible on v36), React Native v0.59 (also reproducible on v0.61). Issue arises on iOS and Android both.