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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@nestjs/graphql): need to properly close websocket servers #2366

Merged
merged 1 commit into from Sep 1, 2022
Merged

fix(@nestjs/graphql): need to properly close websocket servers #2366

merged 1 commit into from Sep 1, 2022

Conversation

jkossis
Copy link

@jkossis jkossis commented Aug 27, 2022

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Currently, we do not properly shutdown the websocket transports (graphql-ws & subscriptions-transport-ws).

It looks like there was some logic removed here (bottom of the graphql-ws-subscription.service.ts diff) that mimics graphql-ws's tear-down logic. And that the net new logic from that diff dupe'd this same behavior (just sending a 1001) for tearing down subscriptions-transport-ws, which doesn't seem reflective of what ApolloServer was doing when they called .close() (back in V2) on the now-deprecated subscriptions-transport-ws's close handler.

I noticed the behavior when my client was receiving the manually sent 1001, but was still able to immediately reconnect. This led me to discovering that we were just sending that code without doing anything else beyond that. I have async tear-down logic in my own OnModuleDestroy's, so the client being able to reconnect and request resources that I was actively trying to tear-down led to the discovery of these issues.

What is the new behavior?

All this to say, I think it makes the most sense to defer the tear-down logic to the libraries/protocols themselves. I am very much open to feedback and discussion on this 馃憤馃徎.

Does this PR introduce a breaking change?

If folks were relying on the server not being properly shut down, then maybe? My gut says no, but interested in what others think.

  • Yes
  • No
  • Maybe

Other information

@jkossis
Copy link
Author

jkossis commented Aug 27, 2022

@kamilmysliwiec, obviously wanna get your thoughts on this.

@kamilmysliwiec
Copy link
Member

LGTM

@kamilmysliwiec kamilmysliwiec merged commit 43e5420 into nestjs:master Sep 1, 2022
@jkossis jkossis deleted the properly-close-ws branch September 1, 2022 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants