Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kael-shipman opened this issue Jan 18, 2019 · 1 comment
Open

Comments

@kael-shipman
Copy link

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:

  • Just update the function to return a promise instead of using the traditional callback technique
  • Update the callback signature to make the error optionally null, which would signal that the request was successful
  • Add an additional callback that is called on success

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
Copy link
Contributor

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants