Humbly asking someone to explain to me what the authors of node.js wrapper 
for Firebase API meant with the following code.
The code is extracted from the official downloadable bundle for node.js 
(file firebase-node.js). 
function fc(a) {
    try {
        a()
    } catch (b) {
        *setTimeout*(function () {
            throw b;
        }, 0)
    }
};

Unfortunately the file is minimized and you can not tell much from function 
and variable names, but debugger shows that this is an interceptor of 
errors which happen in callbacks specified for FB events.
The code in question is the *setTimeout* in catch block.
The implication of such an asynchronous code is that once FB got a bunch of 
events simultaneously (assume 'child_added' event on application start 
which actually reports branch contents on a given key), it first consumes 
them all, reaches a place where an exception is thrown as many times as 
event has occurred, and then starts spitting exceptions as a machine-gun.
Given you catch these unhandled exceptions with a 
*process.on('unhandledException')* handler for example, and do a proper 
.exit(1), you will have the only exception *reported* but multiple 
exceptions *happened*, including all output operations that preceded those 
exceptions in firebase event handlers.

So far I couldn't conclude any benefit if this extra setTimeout in the 
catch block.

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/aa264ab4-abda-4031-b7ec-92b2c34d80ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to