greim / hoxy

Web-hacking proxy API for node
http://greim.github.io/hoxy/
MIT License
599 stars 97 forks source link

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

Closed ZzZombo closed 7 years ago

ZzZombo commented 7 years ago

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 7 years ago

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.