setImmediate

David Bruant bruant.d at gmail.com
Thu Aug 8 07:54:09 PDT 2013


Le 08/08/2013 16:03, Domenic Denicola a écrit :
> To me the answer always seemed obvious: use the slow-script dialog. 
> What am I missing?
Maybe implementations could decide to break a microtask chain, but 
instead of prompting a dialog, they just break it and call a callback 
(later, in a different task, not microtask) so that the script knows and 
can try to recover.

<draft>
asap(f); // queue a microtask;

var microtask = asap(g); // queues a microtask
microtask.on('toolong', h); // if the browser breaks somewhere in this 
microtask subtree, call h
</draft>

You can't know where in the microtask something went wrong, but you can 
try to recover locally. Everyone creating microtasks can do it.

This way, implementations do what they want to preserve the user from 
error without annoying the user with impossible choices (let's be 
honest, the decision to continue or end a script based on a filename and 
line number is absurdly hard to make) and authors can try to recover 
from the partial failures, all locally.

Whad'ya think?

David


More information about the es-discuss mailing list