function connect() {
if (request) {
return
}
readyState = CONNECTING
controller = new AbortController()
request = fetch(url, getRequestOptions())
.then(onFetchResponse)
.catch((err: Error & {type: string}) => {
request = null
// We expect abort errors when the user manually calls `close()` - ignore those
if (err.name === 'AbortError' || err.type === 'aborted') {
return
}
scheduleReconnect()
})
}
https://github.com/rexxars/eventsource-client/blob/d8244e895b0c47bcb15fc4f8dd1f098ed42daa57/src/client.ts#L80C2-L99C4
My understanding based on the code is when there is an error connecting there is no way to know. For my use case I'd like to display something to the user / have some logic to deal with errors like this.
I am planning on using this library - do you want a PR to add an onConnectionError or some other event?
Additionally, I'd like to update the reconnect logic to support some sort of back off strategy, do you want that in the library also?
https://github.com/rexxars/eventsource-client/blob/d8244e895b0c47bcb15fc4f8dd1f098ed42daa57/src/client.ts#L80C2-L99C4
My understanding based on the code is when there is an error connecting there is no way to know. For my use case I'd like to display something to the user / have some logic to deal with errors like this.
I am planning on using this library - do you want a PR to add an onConnectionError or some other event?
Additionally, I'd like to update the reconnect logic to support some sort of back off strategy, do you want that in the library also?