Thanks to @davisp for answering most of the points @benoitc raised - as he says, the existing structure of the CouchDb and Mochiweb parsing code led me to patch them together with a process. I still haven't understood how the desired result can be achieved with callbacks without a fair amount of reworking I'm afraid.