greim/hoxy

Promises don't seem to work alongside interception handlers at all

Closed this issue · 1 comments

I've a replica of my code at https://runkit.com/zzzombo/58dfa8c92830330014a71865 with minor adaptations that shouldn't affect the results. I've tested the response intercept handler, it is never waited for and thus it can't change the response as intended. The output console log is out of order, as indication.

greim commented

This is where I think the problem is:

proxy.intercept(params,(req,res,pxy) =>
{
    fn.forEach((fn) => fn(req,res,pxy));
});

You have to return a promise from that callback otherwise Hoxy has no way of knowing there's anything to wait for.

Hope that helps.