-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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(fetch): Fix memory leak when handling endless streaming #13809
Conversation
This is a quick fix to address a memory overflow issue caused by the recursive approach when handling endless streams (e.g., CCTV). However, this is not a perfect solution, as this approach still does not trigger the onFinishedResolving callback for streams that never terminate. Fixes getsentryGH-13806
adjust format
Hi, thanks for opening the PR! Would you mind outlining the thought process behind the |
Hi, actually the improvement was referenced from GTP. getReader locks the stream and returns either a ReadableStreamDefaultReader or a ReadableStreamBYOBReader. So we need to release the lock and de-activate the reader to ensure that Maybe we can experiment with calling |
btw, we've encountered another issue when working with CCTV streaming. Even after leaving the page and calling videojs.dispose(), the stream continues to fetch data in the background. I think this might require opening a new issue, but could this behavior be related to the code in |
I have updated this PR to:
|
@@ -158,7 +175,8 @@ async function streamHandler(response: Response): Promise<void> { | |||
return; | |||
} | |||
|
|||
await resolveResponse(clonedResponseForResolving, () => { | |||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | |||
resolveResponse(clonedResponseForResolving, () => { |
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.
Why do we want leave this floating?
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 is fine to have floating promises if you are certain that they cannot reject - i think this is the case here!
This is a quick fix to address a memory overflow issue caused by the recursive approach when handling endless streams (e.g., CCTV).
However, this is not a perfect solution, as this approach still does not trigger the onFinishedResolving callback for streams that never terminate.
Fixes GH-13806
Before submitting a pull request, please take a look at our
Contributing guidelines and verify:
yarn lint
) & (yarn test
).The lints didn't pass but they are unrelated to the changes in this commit?
