Skip to content

test: avoid timer race in event loop delay test#64728

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:test-performance-eventloopdelay
Open

test: avoid timer race in event loop delay test#64728
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:test-performance-eventloopdelay

Conversation

@trivikr

@trivikr trivikr commented Jul 25, 2026

Copy link
Copy Markdown
Member

Refs: https://github.com/nodejs/reliability/issues?q=sort%3Aupdated-desc%20test-performance-eventloopdelay

Problem

The test enables the histogram and checks it from a 20 ms timer.

On slow or contended systems, that timer can expire before the first complete event loop iteration.
The timer then disables the histogram before its uv_check callback records a sample.

Previous fixes addressed related but distinct failures:

The failing samplePerIteration checks were added later by #62935 and still depend on elapsed time.

Solution

Drive a known number of event loop iterations using setImmediate before disabling and checking each histogram.

The default-resolution and large-resolution checks share one iteration chain, removing the duplicated timing logic.


Assisted-by: codex:gpt-5.6-sol

An expired timer can run before the first complete event loop
iteration, disabling the histogram before it records any samples.

Drive a known number of iterations with setImmediate before checking
the histograms, and share the chain between resolution variants.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
@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 Jul 25, 2026
@trivikr trivikr added the flaky-test Issues and PRs related to the tests with unstable failures on the CI. label Jul 25, 2026
@trivikr

trivikr commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

@trivikr
trivikr marked this pull request as ready for review July 25, 2026 21:40
@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.12%. Comparing base (9024119) to head (c040df1).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64728      +/-   ##
==========================================
- Coverage   90.15%   90.12%   -0.03%     
==========================================
  Files         743      743              
  Lines      242407   242407              
  Branches    45645    45649       +4     
==========================================
- Hits       218532   218476      -56     
- Misses      15357    15439      +82     
+ Partials     8518     8492      -26     

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

@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flaky-test Issues and PRs related to the tests with unstable failures on the CI. needs-ci PRs that need a full CI run. request-ci Add this label to start a Jenkins CI on a PR. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants