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

Fix issue where subscriptions had no error handling #3800

Merged
merged 6 commits into from
Aug 14, 2018

Conversation

clayne11
Copy link
Contributor

@clayne11 clayne11 commented Aug 10, 2018

Explicitly handle the error case similar to how it is done for
mutations.

Checklist:

  • Make sure all of the significant new logic is covered by tests

@clayne11 clayne11 force-pushed the fix/subscription-errors branch 2 times, most recently from c394454 to 02cd19f Compare August 10, 2018 14:31
Explicitly handle the error case similar to how it is done for
mutations.
@hwillson
Copy link
Member

Thanks for submitting this PR @clayne11! This change makes sense, but I'm a bit worried about backwards compatibility. We might have to wait until we do a major version bump, to get this merged. I'll think about it a bit more, but regardless thanks again!

@hwillson hwillson added this to the Release 3.0 milestone Aug 12, 2018
@hwillson hwillson changed the title Fix issue where subscriptions had no error handling [WIP] Fix issue where subscriptions had no error handling Aug 12, 2018
);
}
return;
if (graphQLResultHasError(result) && obs.error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree with this logic. Regardless of whether or not the observer has an error handler we shouldn't be sending the result to the next handler.

If there is an error handler we should call it, otherwise we should return. The error case should never trickle down to the next handler.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's a mistake. I'm not crazy about seeing return in a forEach as its intent can be misleading, so I was in the process of removing it but clearly didn't finish. I'll adjust - thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait a sec @clayne11 - maybe we can handle this in a backwards compatible way. How about this: If an error handler exists, we call it with the error, and don't call next. If it doesn't, we keep the existing approach of letting the error case trickle down to next. This way people that are already expecting the error to trickle down to next won't be affected (that much). They either have an error handler defined which will now be used, or they don't have one defined and are checking for the error in the result, which will still be there. I think this should cover all of our bases, and let us get this merged now. I'll re-hash the code - let me know what you think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to this solution. If it helps us get this merged more quickly let's do it!

@clayne11
Copy link
Contributor Author

@hwillson it's not really a breaking change IMO, it's a bug fix. There was improper handling of errors before. We're not able to update from graphql@0.11.7 until this gets merged.

It would be great to see this get out sooner than later.

@hwillson
Copy link
Member

hwillson commented Aug 13, 2018

I agree that it's a bug fix, but I'm worried that people have gotten used to working around this bug, and are expecting to deal with the error in the incoming result themselves. These changes will switch that around on them, which might have an unexpected outcome for people. That's why I'm considering it a backwards incompatible change (even though it's a bug fix). I'm happy to be persuaded if you think otherwise though - I'd love to see this get merged.

UPDATE: See #3800 (comment); I think we should be able to get this merged.

@clayne11
Copy link
Contributor Author

clayne11 commented Aug 14, 2018

@hwillson do you think we can get this merged and released today?

@hwillson hwillson changed the title [WIP] Fix issue where subscriptions had no error handling Fix issue where subscriptions had no error handling Aug 14, 2018
@hwillson hwillson removed this from the Release 3.0 milestone Aug 14, 2018
@hwillson hwillson merged commit 657a316 into apollographql:master Aug 14, 2018
@hwillson
Copy link
Member

Done - thanks @clayne11!

@clayne11 clayne11 deleted the fix/subscription-errors branch August 14, 2018 15:00
@clayne11
Copy link
Contributor Author

@hwillson are you planning to cut a release with this soon?

@hwillson
Copy link
Member

@clayne11 Fingers crossed, really soon. I'll try to get a release out today.

@hwillson
Copy link
Member

@clayne11 I haven't forgotten about this; I just want to wrap up #3817 before pushing the next AC version. I'm almost done.

@clayne11
Copy link
Contributor Author

Is it onerous to cut a release? Would it be possible to cut one now then another when you finish that other PR?

@hwillson
Copy link
Member

These changes should be live now @clayne11 (turns out we're going to have to cut an alpha release for #3187). Thanks!

@clayne11
Copy link
Contributor Author

clayne11 commented Aug 17, 2018 via email

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants