Skip to content

[test] Attempt to fix flakiness in test_poll_blocking_asyncify - #27729

Open
sbc100 wants to merge 1 commit into
emscripten-core:mainfrom
sbc100:fix_poll_blocking_flakiness
Open

sbc100 wants to merge 1 commit into
emscripten-core:mainfrom
sbc100:fix_poll_blocking_flakiness

Conversation

@sbc100

@sbc100 sbc100 commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

In test_poll_blocking_asyncify.c, emscripten_set_timeout was called before clock_gettime(CLOCK_MONOTONIC, &begin) in test_unblock_poll. Because Node.js schedules setTimeout relative to its internal millisecond-truncated timestamp (binding.getLibuvNow()), any delay or OS thread scheduling preemption between scheduling the timer and recording begin was subtracted from the measured duration.

Record begin before calling emscripten_set_timeout (matching the pthread-based poll/select blocking tests), switch from hardcoded 1000ms to TIMEOUT_MS (300ms, as done in #26257), normalize negative nanoseconds in timespec_delta_ms, and increase TIMEOUT_MARGIN_MS to 20ms across all blocking poll/select tests.

Fixes: #27727

In `test_poll_blocking_asyncify.c`, `emscripten_set_timeout` was called
before `clock_gettime(CLOCK_MONOTONIC, &begin)` in `test_unblock_poll`.
Because Node.js schedules `setTimeout` relative to its internal
millisecond-truncated timestamp (`binding.getLibuvNow()`), any delay or
OS thread scheduling preemption between scheduling the timer and
recording `begin` was subtracted from the measured duration.

Record `begin` before calling `emscripten_set_timeout` (matching the
pthread-based poll/select blocking tests), switch from hardcoded
`1000`ms to `TIMEOUT_MS` (`300`ms, as done in emscripten-core#26257), normalize
negative nanoseconds in `timespec_delta_ms`, and increase
`TIMEOUT_MARGIN_MS` to `20`ms across all blocking poll/select tests.

Fixes: emscripten-core#27727
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_poll_blocking_asyncify can be flaky in CI

2 participants