Skip to content

test: deflake node-api test-free-called - #65948

Open
christianaurichzm wants to merge 1 commit into
nodejs:mainfrom
christianaurichzm:deflake-node-api-worker-buffer-callback
Open

test: deflake node-api test-free-called#65948
christianaurichzm wants to merge 1 commit into
nodejs:mainfrom
christianaurichzm:deflake-node-api-worker-buffer-callback

Conversation

@christianaurichzm

Copy link
Copy Markdown
Contributor

node-api/test_worker_buffer_callback/test-free-called can fail if the worker exits before the main thread checks that getFreeCallCount() is still 0.

Move the initial check before creating the worker, so it is not dependent on worker scheduling. The test still verifies that the counter starts at 0 and becomes 1 after the worker exits.

This matches the fix previously applied to the equivalent addons test in #51013.

Testing:

$ python3 tools/test.py -j$(nproc) --repeat=500 \
    node-api/test_worker_buffer_callback/test-free-called
[00:48|% 100|+ 500|-   0]: Done

All tests passed.

Refs: #51013
Refs: https://github.com/nodejs/reliability/blob/e457f5b68957d1502256488977bc33b4346d8a4b/reports/2026-09-10.md

`node-api/test_worker_buffer_callback/test-free-called` checks that
`getFreeCallCount()` is 0 on a line that runs after `new Worker()`. The
worker thread can load the addon and run its finalizer before the main
thread reaches that line, in which case the counter is already 1 and the
assertion fails. The zero check is only a baseline, so it does not need
the worker to exist.

Move it above the worker creation. The equivalent test under
test/addons/worker-buffer-callback was changed the same way in
64f7d0e.

Signed-off-by: Christian Aurich <christian.aurichzm@gmail.com>
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. node-api Issues and PRs related to Node-API. test Issues and PRs related to Node.js core tests and test infrastructure. labels Sep 10, 2026
@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.17%. Comparing base (bd9d82d) to head (c7a2f05).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #65948   +/-   ##
=======================================
  Coverage   90.16%   90.17%           
=======================================
  Files         771      771           
  Lines      265485   265485           
  Branches    50466    50470    +4     
=======================================
+ Hits       239381   239401   +20     
+ Misses      17043    17004   -39     
- Partials     9061     9080   +19     

see 23 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. node-api Issues and PRs related to Node-API. test Issues and PRs related to Node.js core tests and test infrastructure.

Projects

Status: Need Triage

Development

Successfully merging this pull request may close these issues.

2 participants