Skip to content

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

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

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

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. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants