node icon indicating copy to clipboard operation
node copied to clipboard

lib: clean up persisted signals when they are settled

Open geeksilva97 opened this issue 1 year ago • 6 comments

Refs #55328 Fixes #55328

This PR adds a finalizer to the non-composed signals used in AbortSignal.any. With that finalizer, those settled signals can be removed from gcPersistentSignals.

Comparison

This comparison shows that settled signals are being collected.

image

geeksilva97 avatar Nov 26 '24 16:11 geeksilva97

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 88.00%. Comparing base (3bb1d28) to head (c11785e). Report is 1415 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #56001      +/-   ##
==========================================
+ Coverage   87.95%   88.00%   +0.04%     
==========================================
  Files         656      656              
  Lines      188310   189010     +700     
  Branches    35963    35993      +30     
==========================================
+ Hits       165630   166330     +700     
+ Misses      15854    15839      -15     
- Partials     6826     6841      +15     
Files with missing lines Coverage Δ
lib/internal/abort_controller.js 98.13% <100.00%> (+0.07%) :arrow_up:

... and 49 files with indirect coverage changes

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Nov 26 '24 20:11 codecov[bot]

CI: https://ci.nodejs.org/job/node-test-pull-request/63725/

nodejs-github-bot avatar Nov 27 '24 17:11 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/63727/

nodejs-github-bot avatar Nov 27 '24 20:11 nodejs-github-bot

Not blocking, but looks like this fixed the repro reported by the OP, but not the one mentioned at #55328 (comment)

Oh, that's the code I used to reproduce locally and ensure the memory stops growing infinitely.

The memory is still pretty high - I think it's because it has those orphan listeners for a while - but it reaches a peak and stops growing forever.

geeksilva97 avatar Nov 28 '24 12:11 geeksilva97

CI: https://ci.nodejs.org/job/node-test-pull-request/63847/

nodejs-github-bot avatar Dec 03 '24 11:12 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/63886/

nodejs-github-bot avatar Dec 05 '24 02:12 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/63923/

nodejs-github-bot avatar Dec 07 '24 10:12 nodejs-github-bot

Landed in 91b6e3c2874b6f6940e6dde5b5d00501d698fd30

aduh95 avatar Dec 08 '24 12:12 aduh95

The added test seems very flaky. For example https://ci.nodejs.org/job/node-test-commit-linuxone/nodes=rhel9-s390x/47103/testReport/junit/(root)/parallel/test_abortsignal_drop_settled_signals/

targos avatar Dec 09 '24 15:12 targos

The added test seems very flaky. For example https://ci.nodejs.org/job/node-test-commit-linuxone/nodes=rhel9-s390x/47103/testReport/junit/(root)/parallel/test_abortsignal_drop_settled_signals/

It is actually. https://github.com/nodejs/node/issues/56190

Should we revert instead of fixing it?

geeksilva97 avatar Dec 09 '24 15:12 geeksilva97

Weirdly, the changes impacted a test that was working before.

geeksilva97 avatar Dec 09 '24 15:12 geeksilva97

You're right. In this example the failure is in drops settled dependant signals when signal is composite. We should probably revert if we don't find a fix quickly

targos avatar Dec 09 '24 15:12 targos

You're right. In this example the failure is in drops settled dependant signals when signal is composite. We should probably revert if we don't find a fix quickly

How much time do I have? I'm investigating it right now.

geeksilva97 avatar Dec 09 '24 15:12 geeksilva97

You're right. In this example the failure is in drops settled dependant signals when signal is composite. We should probably revert if we don't find a fix quickly

How much time do I have? I'm investigating it right now.

I moved this new test to a single file to examine it better.

I'm running tools/test.py --repeat 9999 test/parallel/test-abortsignal-with-listeners.js at this moment

geeksilva97 avatar Dec 09 '24 15:12 geeksilva97

I think I found it, @targos. I will open a PR in a sec.

geeksilva97 avatar Dec 09 '24 15:12 geeksilva97