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 error in @foal/socket.io/lib/socketio-controller.service

See original GitHub issue

Version of FoalTS: 2.8.0

I tried updating my backend but I am still failing at this error:

/node_modules/@foal/socket.io/lib/socketio-controller.service.js:59
                     return cb({
                                ^
 TypeError: cb is not a function
     at Socket.<anonymous> (/node_modules/@foal/socket.io/lib/socketio-controller.service.js:59:28)
     at processTicksAndRejections (node:internal/process/task_queues:94:5)
 Program node ./build/index.js exited with code 1

What can be my problem, did I missed some step in upgrading the project to 2.8?

Thanks

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
LoicPoullaincommented, Feb 18, 2022

Thank you for you investigation. 👍

I found the issue. Setting aside the error that is raised because no response is returned, the TypeError: cb is not a function error comes from the fact that the client does not provide a callback in its emit function:

// Does not work
socket.emit('i am client', {data: 'foo!', id: data.id});

// Works
socket.emit('i am client', {data: 'foo!', id: data.id}, (data) => {
  console.log(data);
});

It appears that, when no callback is provided in the client, the server sdk does not also pass a function to the on method.

1reaction
LoicPoullaincommented, Feb 18, 2022

The issue has been fixed in version 2.8.1 which will be released this week-end. Thank you for reporting this problem @pospile 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebSocket: error event - Web APIs | MDN
The error event is fired when a connection with a WebSocket has been closed due to an error (some data couldn't be sent...
Read more >
WebSocket connection failed: Error during ... - Stack Overflow
Problem solved! I just figured out how to solve the issue, but I would still like to know if this is normal behavior...
Read more >
Websocket error on M1 iMac Monterey · Issue #4746 · tilt-dev/tilt
Inspecting the console there is an error connecting to the websocket: WebSocket connection to 'ws://localhost:10350/w...
Read more >
Error with WebSocket - Microsoft Q&A
Hello I get the error: WebSocket connection to 'wss://localhost:54970/Dashboard.Server/' failed: Error in connection establishment: net:: ...
Read more >
How to resolve the error: "Could not open websocket connection
log messages fail to show. The issue is seen when WebSocket requests are not passed correctly by a reverse proxy or a load...
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