http-party / node-http-proxy

A full-featured http proxy for node.js
https://github.com/http-party/node-http-proxy
Other
13.89k stars 1.97k forks source link

`proxy.web(...)` should provide some way to enable promisification #1319

Open kael-shipman opened 5 years ago

kael-shipman commented 5 years ago

I ran into an error tonight where I was calling proxy.web at the end of an express route handler and because it was asynchronous with no way to confirm success, I had to let it drop through the end of the handler. The problem is that, because it dropped through, when any error happened in the connection, it threw a process-killing error in the global scope, rather than within my defined try/catch block. If the function would in some way indicate success, then I could promisify it and await it, which would allow me to catch the error within my normal flow.

I see three main options:

The first two would be considerably more modern, but of course, would break the current interface, meaning a major version bump. The last one would obviously work without a major bump, but would be more old school.... Let me know if you think there's merit to this.

jsmylnycky commented 5 years ago

Hello! I'm going to be working with the other maintainers to etch out what the next milestone will look like, and I absolutely agree this is most likely a must have. Thanks for your input :)