Description
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. :)