node domain to handle error

this has some potential bugs: if we add some res.doingsometing logic in

d.on("error") callback, then it migth introduce infinite loop and the
exhaust the stack.

we can add a sentinel to only process error callback once.