Azure / Azure/fetch-event-source
Page Visibility based connection retry is not happening in Error scenario
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
As per the current implementation, whenever the page visibility changes the connection will be disconnected & then reconnect only after the page comes back to visibility (during the time of page hidden, no server call is triggered).
But in case of error scenario, even when page is hidden, we are triggering the reconnect request to server.
Sample code to replicate the issue:
```js
fetchEventSource('https://sample.api-service.com/stream', {
openWhenHidden: false,
onopen (res) { throw new Error("Dummy Error"); },
onerror (err) { return 1000; },
}
```
with the above code executed, the connection keeps failing and tries to reconnect for every 1 second.
So far, fine. But when we navigate away from the page (document visibility goes to hidden), even then the server calls are getting triggered in the background.
Need to handle this and make sure that the reconnect calls are not triggers even when page visibility is off.
Contributor guide
Assessment
This issue has not been assessed yet.