Skip to content

test: keep objects alive in finalization fixture - #66869

Open
mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:fix-flaky-unregister-function
Open

mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:fix-flaky-unregister-function

Conversation

@mcollina

Copy link
Copy Markdown
Member

test-process-finalization flakes on Windows CI in the unregister-function.mjs case:

AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

'' !== 'b:exit'

process.finalization holds registered objects only through weak references, and skips the callback at exit if the object is gone. In the fixture, a and b are top-level bindings that no closure captures, so a GC before exit can collect b. Its exit callback then never runs. The same could hide a broken unregister of a.

This references both objects from the exit listener so they stay reachable until the assertion runs.

🤖 Generated with Claude Code

https://claude.ai/code/session_011DQrzezHzwzfCYeh2cYm2U

process.finalization only holds weak references to registered objects.
`a` and `b` were not captured by any closure, so a GC before exit could
collect `b`, skipping its exit callback and failing the assertion.
Reference both objects from the exit listener so they stay reachable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011DQrzezHzwzfCYeh2cYm2U
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to Node.js core tests and test infrastructure. labels Oct 20, 2026
@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.51%. Comparing base (2052d0d) to head (0c42211).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #66869   +/-   ##
=======================================
  Coverage   90.50%   90.51%           
=======================================
  Files         797      797           
  Lines      278195   278221   +26     
  Branches    53453    53472   +19     
=======================================
+ Hits       251777   251825   +48     
+ Misses      16795    16770   -25     
- Partials     9623     9626    +3     

see 39 files with indirect coverage changes

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. test Issues and PRs related to Node.js core tests and test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants