Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested Websocket errors on error returned from the connection #464

Closed
special-character opened this issue May 15, 2020 · 4 comments · Fixed by #476
Closed

Nested Websocket errors on error returned from the connection #464

special-character opened this issue May 15, 2020 · 4 comments · Fixed by #476

Comments

@special-character
Copy link
Contributor

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
The error returned from the error callback gets a heavily nested error that is a WebSocketError

ex:

pusher.connection.bind(
  'error',
  (rawError) => {
    ...
  }
)

The error returned:

{
      type: WebSocketError,
      error: {
        type: WebSocketError,
        error: {
          type: WebSocketError,
          message: "The op coudn't be completedd. Socket is not connected"
        }
      }
    }

If the current behavior is a bug, please provide the steps to reproduce and
if possible a minimal demo of the problem via https://jsfiddle.net or similar.

This is hard to debug but a search on the WebSocketError shows lots of places where errors are involved. I think some might be thrown and wrapped.

https://github.com/pusher/pusher-js/search?q=WebSocketError&unscoped_q=WebSocketError

What is the expected behavior?
Feels like this should be a standard error. I couldn't find a type that matched with this error.

Which versions of Pusher, and which browsers / OS are affected by this issue?
Did this work in previous versions of Pusher? If so, which?

This is specifically happening for pusher-js/react-native

Thanks for the project!

@special-character special-character changed the title Nested Websocket errors on the error returned from the connection Nested Websocket errors on error returned from the connection May 15, 2020
@leesio
Copy link
Contributor

leesio commented Jul 7, 2020

@special-character I think I've been able to recreate this:

2020-07-07 11:48:43.526 [info][tid:com.facebook.react.JavaScript] 'got error from connection', { type: 'WebSocketError',
  error: 
   { type: 'WebSocketError',
     error: { type: 'WebSocketError', error: 'this is an example error' } } }

Screenshot 2020-07-07 at 11 48 23

Can you confirm this is the behaviour you're seeing?

I think this should just be:

{ type: 'WebSocketError', error: 'this is an example error' }

Can you confirm that that's what you're expecting?

@special-character
Copy link
Contributor Author

@leesio this is what I am seeing and I did expect it to be just one websocket error

@leesio
Copy link
Contributor

leesio commented Jul 7, 2020

I think something like this should be fine:
(note: draft PR as I haven't updated tests)

#476

I can't think of a scenario where the error emitted by the TransportConnection or the Connection won't be wrapped sensibly. I could be wrong though, so I'll double check this tomorrow.

@leesio
Copy link
Contributor

leesio commented Jul 31, 2020

Hey @special-character I just released v7.0.0 which includes this fix. Please let me know if this solves your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants