Skip to content
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

Undocumented value replay feature within RetryableOperation presents memory leak #11393

Closed
Hsifnus opened this issue Nov 29, 2023 · 3 comments
Closed

Comments

@Hsifnus
Copy link
Contributor

Hsifnus commented Nov 29, 2023

Issue Description

RetryableOperation, a class exclusively used within RetryLink, stores a private array of values that pushes each and every value emitted through the onNext method of RetryableOperation, which itself is called whenever the RetryLink receives a value through next. The purpose of this value array is to replay all previously emitted values to new subscribers to the request observer returned by RetryLink; however, such functionality is not publicly documented in articles relating to RetryLink, nor does the commit adding said functionality (back when the code was part of apollo-link monorepo) mention why this replay feature was added.

This feature becomes problematic when using a periodic, long-running subscription that emits values through next for an indefinite amount of time without completing, which causes the browser to consume more and more memory over time.

A more thorough description of the issue can be found in this community post

Link to Reproduction

subscription backend: https://codesandbox.io/p/devbox/fervent-gwen-kpkwt5?file=%2F.codesandbox%2Ftasks.json%3A5%2C38

frontend subscription with retry link: https://codesandbox.io/p/sandbox/apollo-subscription-with-auth-forked-tzlw6s?file=%2Fsrc%2FAuthors.tsx

Reproduction Steps

  • With devtools open, click on Debug! button in the frontend playground to initiate a breakpoint when subscription data arrives
  • There should be an entry named RetryableOperation.onNext in the call stack - navigate to this entry
  • Set a log point within the this.onNext function definition that logs this.values.length or something similar
  • Resume and observe the steadily growing values array
@phryneas
Copy link
Member

Could you give the PR release over in #11424 a try and report back if that works for you?

@phryneas
Copy link
Member

The fix for this will be in the next Apollo Client 3.9 beta we will release.

Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants