I'm just starting using domains in nodejs for error management.
There's something I cant understand when I use them with socket.io.
That's my example code:
io.sockets.on('connection', function cb1(socket){
socket.on('event', function cb2(data){
});
});
I started putting all my code in the "run" method
domain.run(function(){
io.sockets.on('connection', function cb1(socket){
socket.on('event', function cb2(data){
});
});
});
But if an error happens in cb1 or cb2 it is not handled!
Then I used the bind methon on che cb1
domain.run(function(){
io.sockets.on('connection', domain.bind(function cb1(socket){
socket.on('event', function cb2(data){
});
}));
});
But if an error happens in cb2 it is not handled!
My question is: do I have to put a single "bind" on every callback? In the server and in the required files?
When I started studied the domains all the tutorials define them like the best solution to handle your errors in one single point!
Am I missing something?