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

Rejected watchQuery promise is uncatchable #891

Closed
jamiter opened this issue Nov 10, 2016 · 2 comments
Closed

Rejected watchQuery promise is uncatchable #891

jamiter opened this issue Nov 10, 2016 · 2 comments
Labels

Comments

@jamiter
Copy link
Contributor

jamiter commented Nov 10, 2016

Intended outcome:
I was trying to use watchQuery and used an error handler when subscribing to updates on the returned observer:

const observer = client.watchQuery({ /* options, no interval */ });

observer.subscribe({
  error: (err) => handleError(err)
})

I expected this to handle the error without any issues.

Actual outcome:
When the underlying query fails it correctly calls the error handler but also prints this in my console:

screen shot 2016-11-08 at 16 57 18

Reproduction:
Subscribe on an observer that was returned by .watchQuery and make it fail (by throwing an error in your resolver on the server for example).

Extra information
There is no way to catch the error because watchQuery handles the query internally and doesn't return the promise anywhere.

The promise seems to be rejected here: https://github.com/apollostack/apollo-client/blob/master/src/core/QueryManager.ts#L959-L973

@helfer
Copy link
Contributor

helfer commented Nov 11, 2016

thanks for reporting this. It's due to two different code paths (watchQuery and refetch) being slightly different. I think we could just suppress the warning by catching the error.

Do you have time to try it in your app and make a quick PR? It would be as simple as adding a catch here.

jamiter added a commit to jamiter/apollo-client that referenced this issue Nov 22, 2016
Fixes apollographql#891

The error wasn't caught anywhere. Should anything be done with the error? For subscriptions it is handled via the store I believe.
jamiter pushed a commit to jamiter/apollo-client that referenced this issue Nov 23, 2016
@jamiter
Copy link
Contributor Author

jamiter commented Nov 23, 2016

@helfer, I created a PR for this. Could you have a look?

Edit: I don't think there is a way to actually test this. Maybe it's possible to see if the console shows the error or not...

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

No branches or pull requests

2 participants