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

Uncaught, unspecified 'error' event. #476

Closed
rlidwka opened this issue Aug 23, 2011 · 0 comments
Closed

Uncaught, unspecified 'error' event. #476

rlidwka opened this issue Aug 23, 2011 · 0 comments

Comments

@rlidwka
Copy link

rlidwka commented Aug 23, 2011

From node.js documentation (http://nodejs.org/docs/v0.4.9/api/events.html):
When an EventEmitter instance experiences an error, the typical action is to emit an 'error' event. Error events are treated as a special case in node. If there is no listener for it, then the default action is to print a stack trace and exit the program.

So, "error" event is treated by node.js as a special case. But socket.io doesn't know it and helpfully emits this event by user request as any other.

If server's developer didn't catch it intentionally, node.js can crash with message "Error: Uncaught, unspecified 'error' event.".

Proof:
server side:
var io = require('socket.io').listen(8888);

client side:
io.connect('127.0.0.1:8888').emit('error');

Of course, anybody can fix that by adding a simple listener:
io.sockets.on('connection', function(conn) {
conn.on('error', function() {
console.log('error catch!');
});
});

But I cant find any word about it on socket.io documentation. So, I suspect that nobody actually thought about it. I think that socket.io should add it own empty listener on every connection to prevent such pointless crashes.

PS: Well... that's VERY funny. Any user can emit "error" and actually generate real server error. :)

@rauchg rauchg closed this as completed in 69941e6 Sep 3, 2011
sgress454 added a commit to sgress454/socket.io that referenced this issue Feb 16, 2017
Includes the following (from engine.io changelog):

* [fix] Initialize the WebSocket server in the Server constructor (socketio#476)
* [chore] Bump ws to version 1.1.2 (vulnerability fix) (socketio#480)
darrachequesne pushed a commit that referenced this issue Feb 16, 2017
Includes the following (from engine.io changelog):

* [fix] Initialize the WebSocket server in the Server constructor (#476)
* [chore] Bump ws to version 1.1.2 (vulnerability fix) (#480)
dzad pushed a commit to dzad/socket.io that referenced this issue May 29, 2023
Includes the following (from engine.io changelog):

* [fix] Initialize the WebSocket server in the Server constructor (socketio#476)
* [chore] Bump ws to version 1.1.2 (vulnerability fix) (socketio#480)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants