question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[2.0] subscribeToMore unsubscribe after first data | bug

See original GitHub issue

I have simple react component with graphql decorator. When component was mounted I am doing subscribeToMore. I will receive first data but immediately after that subscription it stoped working. Component was not unmounted. Am I doing something wrong @jbaxleyiii ? Thank you

@graphql(gql`
  query getUserQuestions($username: String!) {
    user(username: $username) {
      id
      questions {
        edges {
          node {
            id
            question
          }
        }
      }
    }
  }
`, {
  options: ({ match: { params: { username } } }) => ({
    variables: {
      username,
    },
  }),
})
class Test extends Component {
  componentWillMount() {
    const { subscribeToMore, user } = this.props.data;

    this.subscription = subscribeToMore({
      document: SubscribeQuestionAddedQuery,
      variables: {
        username: user.username,
      },
      updateQuery: (prev, { subscriptionData }) => {
        const { data } = subscriptionData;
        if (data && data.questionAdded) {
          this.questionAdded(data.questionAdded);
        }
        return prev;
      },
    });

    console.log(this.subscription);
  }
  ...
}

Here you can see frames from websocket: websocket

As you can see command “stop” is send after first data. Component was not unmount.

    "apollo-cache-inmemory": "^1.1.1",
    "apollo-client": "^2.0.3",
    "apollo-link": "^1.0.3",
    "apollo-link-http": "^1.2.0",
    "apollo-link-batch-http": "^1.0.1",
    "apollo-link-retry": "^1.0.1",
    "apollo-link-dedup": "^1.0.2",
    "apollo-link-ws": "^1.0.1",
    "apollo-utilities": "^1.0.2",

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
andershammar1commented, Mar 19, 2018

Has there been any updates to this issue? We are seeing exactly the same problem in our codebase when introducing apollo-link-state to our link chain. If there is any know workaround, then please share it. Reverting apollo-link-dedup to 1.0.0 did not solve it for us.

0reactions
hwillsoncommented, Aug 5, 2018

Since this is an apollo-link-dedup issue, and is being tracked in https://github.com/apollographql/apollo-link/issues/259, I’ll close it here. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cancel / Unsubscribe GraphQL Subscription
Problem Statement. We use GraphQL subscriptions for the real-time metrics data and show some graphs. When a user clicks on any graph panel, ......
Read more >
how to unsubscribe with useQuery and subscribeToMore
Any associated subscriptions should be unsubscribed for you when the component unmounts. You shouldn't have to manually manage it unless you ...
Read more >
Unsubscribe Settings - Salesforce Help
Enterprise 2.0 admins can manage how their accounts handle business-level unsubscribes in Email Studio. Choose one of the two options under the Properties....
Read more >
mqtt-v5.0.html - MQTT Version 5.0 - OASIS Open
An error that is detected after the packet has been parsed and found to contain data that is not allowed by the protocol...
Read more >
Subscription not working with Apollo Client 2 - Questions
subscribeToMore shows the following error in the console: [Exception: TypeError: 'caller' ... Apollo Client 2.0 is set up like this:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found