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

Promise lints are annoying #219

Open
bouk opened this issue Sep 14, 2016 · 5 comments
Open

Promise lints are annoying #219

bouk opened this issue Sep 14, 2016 · 5 comments

Comments

@bouk
Copy link
Contributor

bouk commented Sep 14, 2016

I keep running into these two lint errors and not knowing what to do

29:3  warning  Expected catch() or return                  promise/catch-or-return
29:3  error    Each then() should return a value or throw  promise/always-return

In the first case I often don't care about the error state and just want it to fail and bugsnag notify when that happens.

In the second case I would be doing something with the result value of a promise, but don't want to chain the promise. Why would I need to return something in that case?

@lemonmade

@marutypes
Copy link

marutypes commented Sep 14, 2016

want it to fail and busnag notify

The issue with this is that promises swallow errors. In fact this can even swallow errors that don't have anything to do with the promises' asynchronous code.

A workaround is manually adding a .catch() in which you rethrow them.

@bouk
Copy link
Contributor Author

bouk commented Sep 14, 2016

@TheMallen rethrowing in a catch won't cause them to be notified either though, right? It'll just get swallowed again

@bouk
Copy link
Contributor Author

bouk commented Sep 14, 2016

I guess in the case where we have bugsnag we can do .catch(Bugsnag.notifyException)

@lemonmade
Copy link
Member

Yeah, the catch one is annoying but prevents a bad and kind of unexpected behaviour of promises, so I think we should leave it and have some sort of catch-all promise handling that people can use easily. I wouldn't really care if we ditch the always-return rule, I've also had cases where I kind of uselessly returned a value to satisfy the rule.

@davidcornu
Copy link
Contributor

  • I wouldn't really care if we ditch the always-return rule, I've also had cases where I kind of uselessly returned a value to satisfy the rule.

    👍

  • I guess in the case where we have bugsnag we can do .catch(Bugsnag.notifyException)

    The downside here is that these won't be reported in tests or in the console

  • I think we should leave it and have some sort of catch-all promise handling that people can use easily

    💯

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

4 participants