-
Notifications
You must be signed in to change notification settings - Fork 2k
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 client delay when subscription is terminated #7849
Fix client delay when subscription is terminated #7849
Conversation
@TylerBloom: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/ |
👷 Deploy request for apollo-server-docs pending review.Visit the deploys page to approve it
|
d872ebc
to
8292730
Compare
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
39c85a4
to
7890c28
Compare
7890c28
to
c7e514c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
860caf4
to
c7e514c
Compare
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @apollo/[email protected] ### Patch Changes - Updated dependencies \[[`c7e514c`](c7e514c)]: - @apollo/[email protected] ## @apollo/[email protected] ### Patch Changes - [#7849](#7849) [`c7e514c`](c7e514c) Thanks [@TylerBloom](https://github.com/TylerBloom)! - In the subscription callback server plugin, terminating a subscription now immediately closes the internal async generator. This avoids that generator existing after termination and until the next message is received. Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This PR addresses #7842 .
When configured with an HTTP callback, a terminated subscription does not fully clean up its resources immediately. Namely, the async generator that the subscription object uses is not closed (i.e.
return()
is not called). This means anything that is await-ing that promise will be waiting until the next message comes through the subscription.The desired behavior is that calling
terminateSubscription
will also end the async generator.To do this, the async generator is stored as a field in the subscription object, and its
return()
method is called in theterminateSubscription
method.