Usually such errors are tiny and non critical, unless you can start to see 
it when you need to build something complex that works reliably.

I didn't experienced any problem with node.js for couple of projects (also, 
I use Fibers and don't have any problems with asynchronous issues at all). 

Until the recent project - web crawler distribute over bunch of machines. 
In my cases it happened in the following scenario - everything works nice, 
and you deploy it. And after half a day half of machines becomes zombie. 
And you start to searching for this sort of tiny problems (also another 
pain in the ass - if sometimes, rarely, some vendor library throws 
unhandled exception you can't intercept and properly destroy something). 

It's very hard to deal with, such bugs can easily take 30% of development 
time, it's especially complex because it's very hard to reproduce.

On Friday, 22 August 2014 12:35:29 UTC+4, Alisson Cavalcante Agiani wrote:
>
> How do people stumble upon this kind of error?
>
>
> On Thu, Aug 21, 2014 at 3:24 PM, Alexey Petrushin <[email protected] 
> <javascript:>> wrote:
>
>> In my understanding the problem is not that it's not possible to prevent 
>> callback from being called twice, with underscore it's as simple as `cb = 
>> _(cb).once()` - but the problem is that it's cumbersome to do it everywhere.
>>
>> On Wednesday, 20 August 2014 00:18:30 UTC+4, Simon Doodkin wrote:
>>>
>>> Not long ago, T.J. complained in an article that he doesn't likes that 
>>> in node.js sometimes callbacks are called more than once.
>>> i have a simple solution for this if you need it. also i can suggest 
>>> that if you have callback problems you could use https://github.com/
>>> mattinsler/longjohn module to trace the problem. id did it several 
>>> times.
>>>
>>> cbguard:  https://gist.github.com/shimondoodkin/a6762d8ab29ea497e245
>>>
>>> // cbguard by Shimon Doodkin - license: public domain
>>>  
>>> function cbguard(cb,printerr){ //kind of filter for callbacks. it prevents 
>>> a callback to be called twice
>>>  var cb1=cb;
>>>  return function() {
>>>   if(cb1) { var cb2=cb1; cb1=false; return cb2.apply(this,arguments); }
>>>   else if(printerr)console.log(new Error('cb called twice').stack);
>>>  }
>>> }
>>>  
>>> // usage example:
>>> //function myfunction(cb)
>>> //{
>>> //  cb=cbguard(cb);  // usage example
>>> // // or
>>> // // cb=cbguard(cb,true);  // good when developing, it will protect and 
>>> also tell you you have a problem, here a callback is called twice here.
>>> //
>>> // things that are based on event emitteres are usually have problems with 
>>> multiple callbacks.
>>>  
>>>
>>>  -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/nodejs/0bfddd86-2dfd-4e35-a3a4-72c323e739b7%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/nodejs/0bfddd86-2dfd-4e35-a3a4-72c323e739b7%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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/1faa6313-be18-4e6c-9dd1-d2419426ded5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to