-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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(core): possible memory leak when using server side events #13453
Conversation
Pull Request Test Coverage Report for Build 872c4fb8-4a0a-4449-b755-a6d8ef9c9301Details
💛 - Coveralls |
@zhengjitf can you share a minimum reproduction of this potential bug? |
@micalevisk Sorry for not having much description for this PR, a minimum is mentioned from #11601 (comment), and I committed a unit test to reproduce this issue before fixing it, (it might be not intuitive?). I’d like to describe my changes, along with investigation: The nest/packages/core/router/sse-stream.ts Lines 119 to 121 in 87cf25a
Then I noticed there is a limitation intention in the following code, but it doesn't work, which I understand is to limit only emitting the value when meanwhile the previous writing is completed (the previous nest/packages/core/router/router-response-controller.ts Lines 131 to 136 in 87cf25a
Based on my understanding, this issue will happen when trying to write a message but meanwhile the previous writing is not completed, this leads to binding more listeners to the A realistic case is mentioned in #11601:
For this case, the issue is likely to happen when the db changes frequently and each pushed event data is large. PS: I didn't run into this issue, I'm trying to implement a SSE route with POST method and did some investigation in the issues panel and source code, then found this issue and hope to make some efforts to address it. I would appreciate it if any misunderstanding or mistakes from me are pointed out. |
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.
It seems to be a clever alternative to do not overload the process.
lgtm |
Closes: #11601
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #11601
What is the new behavior?
Does this PR introduce a breaking change?
Other information