I'm just starting to use domains in nodejs for error management.
There is something I cannot understand when I use them with socket.io.
What is my sample 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 occurred in cb1 or cb2, it is not processed!
Then I used methone binding 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 occurred in cb2, it is not processed!
My question is: do I need to put one “binding” on each callback? On the server and in the necessary files?
When I started to study domains, all the tutorials define them as the best solution to handle your errors at one point!
Did I miss something?
dorexx45
source share