Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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}" log stream`))
} else if (eventSource.readyState == EventSource.CONNECTING) {
// We lost the connection and we're reconnecting... nbd
this.logger.debug("Reconnecting to log stream")
} else if (eventSource.readyState == EventSource.CLOSED) {
// We disconnected for some unknown reason... and presumably exhausted
// attempts to reconnect
reject(new Error(`Encountered unknown error receiving job "${this.name}" log stream`))
}
})
eventSource.addEventListener("done", () => {
setTimeout(function () {
if (es.readyState === EventSource.CLOSED) {
that.emit('error', err);
that.close(true);
}
}, 100);
};
source.addEventListener('error', e => {
if (e.readyState === EventSource.CLOSED) {
console.log('Connection was closed! ', e);
} else {
console.log('An unknown error occurred: ', e);
}
}, false);