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

Audit Promise return values #714

Open
dpogue opened this issue Oct 2, 2018 · 2 comments
Open

Audit Promise return values #714

dpogue opened this issue Oct 2, 2018 · 2 comments
Labels
enhancement hacktoberfest Good issues to be tackled by newcomers as part of Hacktoberfest

Comments

@dpogue
Copy link
Member

dpogue commented Oct 2, 2018

There are too many places where we have very inconsistent return types involving promises. Particularly cases where functions throw, return a resolving promise, and also return a rejecting promise. Also a lot of places where functions return promises that resolve with different value types in different paths.

HookRunner is one spot I've seen that's particularly bad for this, but I've seen it in a few other spots too.

My general recommendation:

  • Any function that returns a promise should never throw. It should reject the promise.
  • Any function that returns a promise should document the resolving value type of that promise, and ensure that only that value type is ever resolved.
@dpogue dpogue added enhancement hacktoberfest Good issues to be tackled by newcomers as part of Hacktoberfest labels Oct 2, 2018
@raphinesse
Copy link
Contributor

Any function that returns a promise should never throw. It should reject the promise.

To clarify: It's OK if throw statements are used in async functions or inside Promise callbacks, because in these cases the Exceptions will be converted into Promise rejections.

@PasunuriSrinidhi
Copy link

To audit a function's return values

  1. Identify the expected return values.
  2. Review the function code.
  3. Test the function with different input values.
  4. Check error handling.
  5. Consider side effects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement hacktoberfest Good issues to be tackled by newcomers as part of Hacktoberfest
Projects
None yet
Development

No branches or pull requests

3 participants