Skip to content

Fix flaky TaskDispatchThreadTest/RunAsyncWithDelay timing test#57041

Closed
cortinico wants to merge 1 commit into
facebook:mainfrom
cortinico:export-D107232190
Closed

Fix flaky TaskDispatchThreadTest/RunAsyncWithDelay timing test#57041
cortinico wants to merge 1 commit into
facebook:mainfrom
cortinico:export-D107232190

Conversation

@cortinico
Copy link
Copy Markdown
Contributor

Summary:
Replace tight sleep_for margins with a std::promise/std::future synchronization pattern. The old test used sleep_for(50ms) and sleep_for(70ms) to bracket a 100ms delayed task, which failed on loaded CI machines when timers fired early or late (98.7% flakiness score). The new approach uses sleep_for(20ms) for the "not yet executed" check (well before the 200ms delay) and future.wait_for(5s) for the "completed" check, eliminating timing sensitivity entirely.

Changelog: [Internal]

Differential Revision: D107232190

Summary:
Replace tight `sleep_for` margins with a `std::promise`/`std::future` synchronization pattern. The old test used `sleep_for(50ms)` and `sleep_for(70ms)` to bracket a 100ms delayed task, which failed on loaded CI machines when timers fired early or late (98.7% flakiness score). The new approach uses `sleep_for(20ms)` for the "not yet executed" check (well before the 200ms delay) and `future.wait_for(5s)` for the "completed" check, eliminating timing sensitivity entirely.

Changelog: [Internal]

Differential Revision: D107232190
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 2, 2026
@facebook-github-tools facebook-github-tools Bot added p: Facebook Partner: Facebook Partner labels Jun 2, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Jun 2, 2026

@cortinico has exported this pull request. If you are a Meta employee, you can view the originating Diff in D107232190.

@meta-codesync meta-codesync Bot closed this in e208aa0 Jun 2, 2026
@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @cortinico in e208aa0

When will my fix make it into a release? | How to file a pick request?

@react-native-bot react-native-bot added the Merged This PR has been merged. label Jun 2, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Jun 2, 2026

This pull request has been merged in e208aa0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants