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

LRU cache is not releasing thread on api.disconnect() if you've written to the chain. #6010

Closed
2 of 9 tasks
sicco-moonbeam opened this issue Oct 28, 2024 · 6 comments · Fixed by #6013
Closed
2 of 9 tasks
Assignees
Labels
Bug Tracks issues causing errors or unintended behavior, critical to fix for reliability. P0 - Urgent Highest priority, critical to project success. Needs immediate resolution to prevent delays.

Comments

@sicco-moonbeam
Copy link

  • I'm submitting a ...

    • [x ] Bug report
    • Feature request
    • Support request
    • Other
  • What is the current behavior and expected behavior?

In version 14.1.1, Node.js retains a thread after writing to the chain, even when api.disconnect() is called. While reading chain state behaves as expected, any write operation—such as a simple balances.transfer—prevents the Node.js process from terminating automatically. The attached WTFNode output shows that the hanging process originates in node_modules@polkadot\rpc-provider\cjs\lru.js:115.

I'm not entirely sure when this was introduced as I was previously on 10.11.2 but I suspect it's fairly recent - I noticed references to changes to the LRU cache in the last few commits.

  • What is the motivation for changing the behavior?

api.disconnect() should gracefully release all resources. In a long-running process, this would result in a memory leak.

  • Please tell us about your environment:

    • Version:

    • Environment:

      • Node.js - tested on latest stable version (v23.1.0) but can reproduce on older versions
      • Browser
      • Other (limited support for other environments)
    • Language:

      • JavaScript
      • TypeScript (include tsc --version) - 5.6.3
      • Other
@TarikGul
Copy link
Member

Yes this would be related to #5997

cc: @filvecchiato

@TarikGul TarikGul added the P1 - High Essential for progress, blocks other tasks. Must be completed soon to maintain project flow. label Oct 28, 2024
@TarikGul TarikGul added the Bug Tracks issues causing errors or unintended behavior, critical to fix for reliability. label Oct 28, 2024
@sicco-moonbeam
Copy link
Author

I can confirm it was introduced in 14.1.1 - downgrading to 14.0.1 fixed it for me.

@filvecchiato filvecchiato self-assigned this Oct 29, 2024
@xlc
Copy link
Contributor

xlc commented Oct 31, 2024

I just spent 2 hours debugging why chopsticks no longer exit cleanly... Please add some regression tests.

@TarikGul
Copy link
Member

I just spent 2 hours debugging why chopsticks no longer exit cleanly... Please add some regression tests.

Yes, we are actively getting this fixed ASAP and adding tests!

@TarikGul TarikGul added P0 - Urgent Highest priority, critical to project success. Needs immediate resolution to prevent delays. and removed P1 - High Essential for progress, blocks other tasks. Must be completed soon to maintain project flow. labels Oct 31, 2024
@TarikGul TarikGul moved this from P1 - High to P0 - Urgent in Polkadot-js general project board Oct 31, 2024
@filvecchiato filvecchiato linked a pull request Oct 31, 2024 that will close this issue
@github-project-automation github-project-automation bot moved this from P0 - Urgent to Done in Polkadot-js general project board Oct 31, 2024
@TarikGul
Copy link
Member

PR is in and a patch release will be up soon

@polkadot-js-bot
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators Nov 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Tracks issues causing errors or unintended behavior, critical to fix for reliability. P0 - Urgent Highest priority, critical to project success. Needs immediate resolution to prevent delays.
Development

Successfully merging a pull request may close this issue.

5 participants