lukeed / sockette

The cutest little WebSocket wrapper! 🧦
MIT License
2.45k stars 81 forks source link

onerror not returning code #45

Closed Eli-Black-Work closed 5 years ago

Eli-Black-Work commented 5 years ago

Hello,

The documentation for onerror says "Important: If the event.code is ECONNREFUSED, an automatic reconnect attempt will be queued."

However, when doing onerror: e => console.log('Error:', e), it looks like e.code doesn't exist.

lukeed commented 5 years ago

It's not meant to have a code key – it can & when it is a ECONNREFUSED code, a reconnect will be attempted.

The onerror (primarily) receives Events or ErrorEvents. It's the CloseEvent (via onclose) that will always have a numerical code property. Sockette will reconnect if the connection was not closed with a code of 1000 or 1005.

Hope that helps a bit~!

Eli-Black-Work commented 5 years ago

Thanks, @lukeed :)