test: deflake node-api test-free-called - #65948
Open
christianaurichzm wants to merge 1 commit into
Open
Conversation
`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>
Codecov Report✅ All modified and coverable lines are covered by tests. 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 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
node-api/test_worker_buffer_callback/test-free-calledcan fail if the worker exits before the main thread checks thatgetFreeCallCount()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:
Refs: #51013
Refs: https://github.com/nodejs/reliability/blob/e457f5b68957d1502256488977bc33b4346d8a4b/reports/2026-09-10.md