sse.js icon indicating copy to clipboard operation
sse.js copied to clipboard

Unhandled errors - more info

Open dragos-miron opened this issue 1 year ago • 1 comments

Hello!

I've recently encountered a CORS error when trying to create the SSE connection - the 'error' event was dispatched, but it does not have any information about the CORS error which appeared in the console. The only clue that we receive in the error event is a responseCode:0 - would it be possible to include the unhandled error which caused this in the error object?

  this._onStreamFailure = function(e) {
    const event = new CustomEvent('error');
    event.responseCode = e.currentTarget.status;
    event.data = e.currentTarget.response;
    this.dispatchEvent(event);
    this._markClosed();
  }
// maybe send the whole e object?

Thanks!

dragos-miron avatar Sep 17 '24 14:09 dragos-miron

@dragos-miron Is that error detail in the original XHR error event passed to onStreamFailure?

mpetazzoni avatar Sep 19 '24 18:09 mpetazzoni