Skip to content

subscribeToMore disconnects on GraphQL error #877

@tpodom

Description

@tpodom

Describe the bug
When using subscribeToMore, if one of the resolvers throws an error on the server, the client receives a GraphQL error which initiates a subscription shutdown. I tried adding an onError callback but the Observerable.notifySubscription just unconditionally closes the subscription when an error is received.

I have the reconnect: true option set on the WebSocketLink but the problem is that the subscription ends even though the websocket link is still alive.

Would the best workaround be to not use the subscribeToMore option on the query definition and instead have a method that calls the subscribeToMore and onError re-call that method to re-establish the subscription?

To Reproduce
Steps to reproduce the behavior:

  1. Define a smart query with a subscribeToMore
  2. Publish a message on the server
  3. Throw an error from a resolver on the server
  4. You'll see that the server receives a stop message in the websocket frames
  5. Publish another message on the server
  6. Since the stop message was sent, the new publish is never processed

Expected behavior
I would expect the subscription to either re-connect or stay alive when an exception occurs.

Versions
vue: 2.6.10
vue-apollo: 3.0.0
apollo-client: 2.6.4

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions