-
Notifications
You must be signed in to change notification settings - Fork 1
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
Duplicate GraphQL subscriptions sent #11
Comments
I have got to the bottom of why duplicate subscriptions are sometimes sent from the web application and I have developed a fix. There were two issues to address:
I have run several tests monitoring the number of connections in Coniql as well as the memory usage. This fixes the issue under any of the following circumstances:
I have also updated the tests and added a new one to check that the |
@AlexanderWells-diamond We should check whether the same issue exists in the pts app, as likely you followed some similar patterns to cs-web-proto. |
I have certainly seen similar a similar issue - on my development setup I see a GraphQL connection to Coniql established and then closed every minute. Strangely this does not happen in the deployed Production build. I also note that the PTS app does not use the SubscriptionClient, instead using ApolloClient and its |
Adding link to another related issue in Coniql resulting in duplicate subscriptions: DiamondLightSource/coniql#34 |
Fixed with #12 |
This issue relates to the memory leak found in the Coniql application: DiamondLightSource/coniql#35
While debugging the memory leak in the Coniql application, I came across an issue in the GraphQL subscription mechanism in the cs-web-lib code. I was able to consistently reproduce a case that caused the memory leak in Coniql and one that did not.
Memory leak: This occurs when the a page is loaded which is subscribing to PVs through Coniql, but Coniql has not yet been started (or has been taken down). When the page loads, the
subscribe
commands are sent from the web app. As Coniql has not yet been started, the application performs anunsubscribe
after a disconnect. When Coniql is started, the web app sends anothersubscribe
on reconnection. The previous subscribe on start up has not been cancelled (for some reason) and so 2 subscribes are picked up by Coniql. One of these is old and appears to not be attached to a client - this might be what is causing the memory leak.No memory leak: If Coniql is already running before a web page subscribing to PVs is loaded then there is no memory leak. The
subscribe
is sent once and only once. Note that if you then bring Coniql down and restart it, we will end up in the first situation and get a memory leak.Possibly something wrong with the unsubscribe that is not clearing the initial subscription on disconnect.
The text was updated successfully, but these errors were encountered: