|
|
@@ -7,7 +7,6 @@ class SseSource {
|
|
|
protected readonly onClose: (() => void)
|
|
|
protected readonly withCredentials: boolean
|
|
|
protected eventSource: EventSourcePolyfill | null = null
|
|
|
-
|
|
|
constructor(
|
|
|
mercureHubBaseUrl: string,
|
|
|
topic: string,
|
|
|
@@ -49,7 +48,11 @@ class SseSource {
|
|
|
this.eventSource = this.createEventSource(this.url.toString(), this.withCredentials)
|
|
|
|
|
|
this.eventSource.onerror = (event) => {
|
|
|
- console.error('SSE - An error happened')
|
|
|
+ if (event.target.readyState === EventSource.CLOSED) {
|
|
|
+ console.log("SSE closed (" + event.target.readyState + ")");
|
|
|
+ }
|
|
|
+ // @ts-ignore
|
|
|
+ this.eventSource.close();
|
|
|
}
|
|
|
this.eventSource.onopen = () => {
|
|
|
console.log('SSE - Listening for events...')
|