Yaffle / EventSource

a polyfill for http://www.w3.org/TR/eventsource/
MIT License
2.11k stars 338 forks source link

How to handle errors? Non-minified version prints `undefined` error #159

Closed mkrakiewicz closed 3 years ago

mkrakiewicz commented 3 years ago

Hi, I'm trying to subscribe with auth to Mercure. The native EventSource works OK without authentication. But I need auth so I'm trying to use this polyfill.

TLDR: the minified version of this lib (1.0.20) works OK, but development version throws me errors constantly. The minified version has stripped console.error calls but I would like to handle this properly if there is something wrong.

When I use non-minified version of this lib I get errors every ~15 seconds:

Zrzut ekranu 2020-09-24 o 10 51 06 Zrzut ekranu 2020-09-24 o 10 53 49

The code still works, but the errors are unexpected.

How to handle those errors / reconnects properly? Because this doesn't happen in the native EventSource.

EDIT:

I've degraded version to 1.0.19 and the console log is removed and I can use a listener to get errors manually.

dlong500 commented 3 years ago

@Yaffle It looks like the console logging on that particular line was only added in v1.0.20. Can you clarify why it is needed?

Yaffle commented 3 years ago

looks like that line should be removed