-
Notifications
You must be signed in to change notification settings - Fork 575
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
Subscriptions fire multiple times #101
Comments
Any news on this @schickling? |
For me it doesn't get fired :( |
@tfiwm can you share a link to your repo so we can reproduce your issue? |
Might be related to this, @tfiwm: https://github.com/graphcool/prisma/issues/1734 |
I'm experiencing this as well:
|
@tfiwm found out that this is easily reproduced when refreshing the browser. Then a new connection is created, but old connections are also set up again. |
Is this reproducable in the playground? Or just combined with the apollo-client? |
It's reproducible with this "subscription client": https://gist.github.com/marktani/5df524523693c88be425bfb623ca8b8a |
Note that this observation might be a different phenomenon than what @nikolasburk originally reported. It might be two separate problems, client and server side. |
https://github.com/oxy88/prisma_subscription
|
@oxy88 Your steps description seems to indicate that |
Anyone have an update here? I'm not sure if this is I currently have a work around to ignore duplicate subscription messages, but it's less than ideal 😅 |
We are currently looking into this with a fix coming up soon 🙂 |
I did a PR to graphql-tools, as soon as it's merged, the problem is fixed. ardatan/graphql-tools#609 |
The fix was merged and is available in version Thanks everyone for feedback and help to pinpoint this issue 🙌 |
This problem still happens while using the managed Graphcool service |
@darmie maybe worth opening a new issue? |
This problem still happens while using Prisma |
any word on this? Still happens when using prisma |
@nikolasburk I was doing your tutorial with react and apollo on howtographql.com, and I seam to figure out why subscriptions fire multiple times. The number of firing doesn't depend on number of requests on server but rather on number of renderings of Query component in LinkList, each time receiving new data from subscription, LinkList component rerender Query and makes new subscription for the same data, and then get it multiple times per request. I solved this issue with dirty fix by wrapping subscription functions with flags, that prevent Query from subscribing multiple times. Here is your LinkList code with my fixes. `import React, { Component } from 'react' export const FEED_QUERY = gql const NEW_LINKS_SUBSCRIPTION = gql const NEW_VOTES_SUBSCRIPTION = gql
} export default LinkList` I think that problem is that subscriptions should be registered on mount and unregistered on unmount of the component. Hope that helps, Best regards, PS. I opened an issue on react-apollo apollographql/react-apollo#2656 |
Was able to do it by passing subscribeToMore into a child component and subscribing in componentDidMount |
I think that's valid approach, but you should be careful to unregister subscription on componentWillUnmount in case the whole component will be rerendered upon link change or some other scenarios, |
Hey, @Urigo from The Guild here! You might know us from projects such as graphql-code-generator, envelop or graphql-tools. For a long time we thought that the Javascript ecosystem is still missing a lightweight cross-platform, but still highly customizable GraphQL Server. In the past the awesome Prisma team took on that great challenge and now we are happy to announce that we are continuing them and just released GraphQL Yoga 2.0 - Build fast, extensible, and batteries-included (Subscriptions, Serverless, File uploads support) GraphQL APIs in Node.js 🚀 We have been working a long time on version 2.0 and have been using it in our clients projects for a few months now and shared a couple of alpha cycles here. Please try Yoga out again, give us feedback and help us spread the word on the new release! |
I have an issue where the subscriptions are firing multiple times per event when they should only fire once. The number of times the subscriptions fire increases the more requests the server receives.
The issue can be reproduced with this project: https://github.com/howtographql/react-apollo/tree/gc-1.0
The text was updated successfully, but these errors were encountered: