question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"WebSocket is already in CLOSING or CLOSED state" on sending event before disconnecting

See original GitHub issue

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

What is the current behavior? Sending event right before pusher disconnect call leads to WebSocket is already in CLOSING or CLOSED state error (and also no event sent).

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.

pusherChannel.trigger('evenName', { field: 'value' });
pusher.disconnect();

// `WebSocket is already in CLOSING or CLOSED state.` in console no event sent

Looks like this deferred sending callback https://github.com/pusher/pusher-js/blob/807b778463851f3a9b02114abf06f00f65e94d8f/src/core/transports/transport_connection.ts#L134 is invoked before onClose call and socket cleanup https://github.com/pusher/pusher-js/blob/807b778463851f3a9b02114abf06f00f65e94d8f/src/core/transports/transport_connection.ts#L165 but socket is already in closing state at that time

What is the expected behavior? Event has been sent, no error in console

Which versions of Pusher, and which browsers / OS are affected by this issue? Did this work in previous versions of Pusher? If so, which? pusher-js: 4.2.2., 5.0.3 Chrome 79

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

2reactions
artaommahecommented, Apr 22, 2021

😕

0reactions
stale[bot]commented, Jul 21, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you’d like this issue to stay open please leave a comment indicating how this issue is affecting you. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - How to catch and deal with "WebSocket is already ...
The easiest way is to check if the socket is open or not before sending. For example - write a simple function: function...
Read more >
WebSocket is already in CLOSING or CLOSED state. ERROR
WebSocket is already in CLOSING or CLOSED state means that the connection has been disconnected and data cannot be sent through this ......
Read more >
WebSocket: close event - Web APIs - MDN Web Docs
Returns a string indicating the reason the server closed the connection. This is specific to the particular server and sub-protocol.
Read more >
How to Avoid Multiple WebSocket Connections in a React ...
It creates a WebSocket connection with Stream, and it sends and receives events and payloads from the server.
Read more >
Using websockets — Quart 0.17.0 documentation
if the websocket is closed before it is accepted the server will respond with a 403 HTTP response. Testing websockets#. To test a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found