Skip to content

test: add retry logic for eventloopdelay histogram sampling#61796

Open
mcollina wants to merge 2 commits intonodejs:mainfrom
mcollina:fix-flaky-test-performance-eventloopdelay-v2
Open

test: add retry logic for eventloopdelay histogram sampling#61796
mcollina wants to merge 2 commits intonodejs:mainfrom
mcollina:fix-flaky-test-performance-eventloopdelay-v2

Conversation

@mcollina
Copy link
Member

Summary

Fixes flaky test-performance-eventloopdelay test on sharedlibs builds.

Problem

On some build configurations (e.g., Ubuntu 24.04 sharedlibs), the histogram may not record valid samples (min > 0) after the initial spinning period. The test fails with:

AssertionError [ERR_ASSERTION]: assert(histogram.min > 0)

The previous fix (PR #61629) added setImmediate to allow samples to be recorded, but this wasn't sufficient for all configurations.

Solution

Add a retry mechanism that checks if valid samples have been recorded (count > 0 && min > 0 && max > 0). If not, the test will spin the event loop additional times (up to 3 retries) before asserting.

This ensures the test passes on slower or differently-configured systems where event loop delay sampling may take longer to produce measurable results.

Verification

Tested locally with python3 tools/test.py --repeat 30 - all passed.

Refs: nodejs/reliability#1461

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Feb 12, 2026
@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.71%. Comparing base (4a13a62) to head (64c291a).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61796      +/-   ##
==========================================
- Coverage   89.76%   89.71%   -0.05%     
==========================================
  Files         675      675              
  Lines      204674   204797     +123     
  Branches    39330    39348      +18     
==========================================
+ Hits       183716   183734      +18     
- Misses      13235    13336     +101     
- Partials     7723     7727       +4     

see 52 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.

On some build configurations (e.g., sharedlibs), the histogram may not
record valid samples (min > 0) after the initial spinning period. This
adds a retry mechanism that will spin the event loop additional times
if valid samples haven't been recorded yet.

This helps ensure the test passes on slower or differently-configured
systems where event loop delay sampling may take longer to produce
measurable results.

Refs: nodejs/reliability#1461
@mcollina mcollina force-pushed the fix-flaky-test-performance-eventloopdelay-v2 branch 2 times, most recently from a0b9aa0 to ad1c0a7 Compare February 13, 2026 10:43
Extract assertions into separate function and simplify control flow.
Use setImmediate for final assertions to ensure histogram has
recorded all samples.
@mcollina mcollina force-pushed the fix-flaky-test-performance-eventloopdelay-v2 branch from ad1c0a7 to 64c291a Compare February 14, 2026 16:48
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 the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants