How to use the eventsource.CONNECTING function in eventsource

To help you get started, we’ve selected a few eventsource examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github brigadecore / brigade / v2 / brigadier-polyfill / src / jobs.ts View on Github external
eventSource.addEventListener("error", (e: any) => { // eslint-disable-line @typescript-eslint/no-explicit-any
        if (e.status) { // If the error has an HTTP status code associated with it...
          eventSource.close()
          reject(new Error(`Received ${e.status} from the API server when attempting to open job "${this.name}" status stream`))
        } else if (eventSource.readyState == EventSource.CONNECTING) {
          // We lost the connection and we're reconnecting... nbd
          this.logger.debug("Reconnecting to status stream")
        } else if (eventSource.readyState == EventSource.CLOSED) {
          // We disconnected for some unknown reason... and presumably exhausted
          // attempts to reconnect
          reject(new Error(`Error receiving job "${this.name}" status stream: ${e.message}`))
        }
      })
    })

eventsource

W3C compliant EventSource client for Node.js and browser (polyfill)

MIT
Latest version published 2 years ago

Package Health Score

75 / 100
Full package analysis