-
Notifications
You must be signed in to change notification settings - Fork 133
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
Fix memory leak in withFilter cause by recursion #209
Fix memory leak in withFilter cause by recursion #209
Conversation
@urossmolnik: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
any updates on this PR? |
I also have memory leaks using this package. It would be nice if this PR could be merged. |
same here |
Would also like to see this merged. |
➕ |
@apollo-cla what do you think about this PR? This PR has been waiting for 5 months. please write a feedback about this PR. |
@nurettintopal I signed agreement. |
The typescript errors still need to be fixed.
|
@OmgImAlexis these are not related to this pull request. Should I fix them as part of it? |
Maybe in another PR? This would need to be merged after that though. |
Hi! Any updates on this issue? |
@OmgImAlexis sorry missed this. I just pushed changes to this pull request. Hope this is ok. |
Also seeing this issue after investigating many of our nodes running this code were experiencing memory leaks. Heap snapshots revealed lots of memory was being eaten from this leaked variable. |
@grantwwu any chance on this being merged soon? |
I am no longer working on GraphQL, sorry. Please try to contact someone from Apollo for maintenance of this repo. |
Could you please tag in the right person/team? I’d tag a team but I couldn’t see anything come up when I tried looking for them. |
I don't/didn't work at Apollo. Your best bet for contacting them might be the Apollo Spectrum https://spectrum.chat/apollo?tab=posts. I don't know who on their side is supposed to be interacting with the open source community. When I was still working on GraphQL at my last job, after initially having some success working with Apollo devs to make improvements, I found it harder and harder to reach out to them to get things reviewed or to get help with how graphql-subscriptions interacted with other components of the GraphQL ecosystem. (I actually still have an unmerged bugfix PR #205.) That, and the fact that I am not using GraphQL at all in my job, is why I stopped spending time on this. |
Well, @hwillson is the most recent Apollo team member to push to this repo, so hopefully this is the right person to ping |
…ns into fix-withfilter-memory-leak
50aa496
to
0205880
Compare
0205880
to
b7c7472
Compare
@glasser what're the odds in getting this merged after the build is fixed? |
04d2aa8
to
835ab5f
Compare
I plan to review it soon, but since I'm not super familiar with this package and memory leaks are subtle, I know it will take at least a bit of care. I'm about to take a week of vacation so don't expect any activity before the 22nd at the earliest! |
this is a visualization of running the same load test before the suggested change in this PR and then after. in the asynchronous resources chart, notice the long tail in the first group (before the change in this PR). this is because each filtered event results in an unresolved promise that is kept in memory. these accumulate over time and can trigger crashes/restarts with high throughput. shoutout to @urossmolnik @OmgImAlexis for the fix 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to say: I don't quite understand precisely why the original code causes the issue or how the new code avoids the issue.
But the new code does appear to have the same high-level semantics as the old code, and the test is VERY convincing. So I'll merge and release.
Released in 1.2.1. |
withFilter
function is causing memory leak because of Promise spec. Related: nodejs/node#6673.This is a big problem when you have long living subscriber to subscription who skips most of messages (all Promises in recursion chain are kept in memory).
How to reproduce:
Start a subscriber to a subscription which rejects messages and start publishing messages. You'll notice memory keeps increasing. Memory profile will confirm.
Do the same thing using refactored
withFilter
and you'll notice memory is not increasing.Pull Request Labels
Fixes #212