Skip to content

Deflake TaskDispatchThreadTest.MultipleDelayedTasksOrder - #57830

Closed
cortinico wants to merge 1 commit into
react:mainfrom
cortinico:export-D114605936
Closed

Deflake TaskDispatchThreadTest.MultipleDelayedTasksOrder#57830
cortinico wants to merge 1 commit into
react:mainfrom
cortinico:export-D114605936

Conversation

@cortinico

Copy link
Copy Markdown
Contributor

Summary:
WARNING: Generated by Autopilot (alpha) — review carefully, verify the underlying claim before accepting.
Agent: React Native Oncall Tests Fixer | Trajectory: https://www.internalfb.com/intern/devai/devmate/inspector/0bb8944e-85d4-4a86-ac19-5147b3b0a48f/ | SC job: https://www.internalfb.com/intern/sandcastle/instance/36028799852645402/


TaskDispatchThreadTest/MultipleDelayedTasksOrder (test_id 562950261618811)
is a timing-sensitive GTest that schedules two delayed tasks (at 50ms and
100ms) and then races a fixed std::this_thread::sleep_for(120ms) against
the 100ms deadline before asserting results.size() == 2. Only 20ms of slack
covers the later task, so under CI load / emulator scheduling jitter the
second task has not run when the assertion fires, producing the observed
results.size() is 0 or 1 failure at line 79. TestX reports a 95.7% simple
flakiness score for this test, and it has a long history of auto-closed
FLAKY issues; it recently surfaced as a hard FAILURE (issue 233255291).

Replace the fixed sleep with deterministic synchronization on the later
task using the same std::promise/future.wait_for pattern already used by
RunAsyncWithDelay in this file. Because both tasks run serially on the
single dispatch thread in deadline order, blocking until the 100ms task
completes guarantees the 50ms task has already run, and waiting on the future
establishes the happens-before needed to read results safely.

Differential Revision: D114605936

Summary:
WARNING: Generated by Autopilot (alpha) — review carefully, verify the underlying claim before accepting.
Agent: React Native Oncall Tests Fixer | Trajectory: https://www.internalfb.com/intern/devai/devmate/inspector/0bb8944e-85d4-4a86-ac19-5147b3b0a48f/ | SC job: https://www.internalfb.com/intern/sandcastle/instance/36028799852645402/

---

`TaskDispatchThreadTest/MultipleDelayedTasksOrder` (test_id 562950261618811)
is a timing-sensitive GTest that schedules two delayed tasks (at 50ms and
100ms) and then races a fixed `std::this_thread::sleep_for(120ms)` against
the 100ms deadline before asserting `results.size() == 2`. Only 20ms of slack
covers the later task, so under CI load / emulator scheduling jitter the
second task has not run when the assertion fires, producing the observed
`results.size()` is 0 or 1 failure at line 79. TestX reports a 95.7% simple
flakiness score for this test, and it has a long history of auto-closed
FLAKY issues; it recently surfaced as a hard FAILURE (issue 233255291).

Replace the fixed sleep with deterministic synchronization on the later
task using the same `std::promise`/`future.wait_for` pattern already used by
`RunAsyncWithDelay` in this file. Because both tasks run serially on the
single dispatch thread in deadline order, blocking until the 100ms task
completes guarantees the 50ms task has already run, and waiting on the future
establishes the happens-before needed to read `results` safely.

Differential Revision: D114605936
@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 Aug 5, 2026
@facebook-github-tools facebook-github-tools Bot added p: Facebook Partner: Facebook Partner labels Aug 5, 2026
@meta-codesync

meta-codesync Bot commented Aug 5, 2026

Copy link
Copy Markdown

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

@meta-codesync meta-codesync Bot closed this in 0b3ca28 Aug 5, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Aug 5, 2026
@meta-codesync

meta-codesync Bot commented Aug 5, 2026

Copy link
Copy Markdown

This pull request has been merged in 0b3ca28.

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

1 participant