Skip to content

Fix flaky EventTargetDispatching-itest error handling test#57042

Closed
cortinico wants to merge 2 commits into
react:mainfrom
cortinico:export-D107232191
Closed

Fix flaky EventTargetDispatching-itest error handling test#57042
cortinico wants to merge 2 commits into
react:mainfrom
cortinico:export-D107232191

Conversation

@cortinico

Copy link
Copy Markdown
Contributor

Summary:
When enableNativeEventTargetEventDispatching is enabled, EventTarget.js defers handler errors via setTimeout(0) in reportListenerError, making them non-deterministically visible to a synchronous toThrow assertion (96.6% flakiness score). When toThrow misses the error, it leaks as an uncaught exception into the next test ("event timestamps"), causing a cascade failure.

Gate the toThrow assertion on the legacy code path where errors propagate synchronously via rethrowCaughtError. In the new EventTarget path, dispatch the event and drain any pending errors via Fantom.runTask to prevent test pollution. The core assertion (parentHandler called despite child error) runs in both paths.

Changelog: [Internal]

Differential Revision: D107232191

cortinico added 2 commits June 2, 2026 03:45
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:
When `enableNativeEventTargetEventDispatching` is enabled, `EventTarget.js` defers handler errors via `setTimeout(0)` in `reportListenerError`, making them non-deterministically visible to a synchronous `toThrow` assertion (96.6% flakiness score). When `toThrow` misses the error, it leaks as an uncaught exception into the next test ("event timestamps"), causing a cascade failure.

Gate the `toThrow` assertion on the legacy code path where errors propagate synchronously via `rethrowCaughtError`. In the new EventTarget path, dispatch the event and drain any pending errors via `Fantom.runTask` to prevent test pollution. The core assertion (`parentHandler` called despite child error) runs in both paths.

Changelog: [Internal]

Differential Revision: D107232191
@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

meta-codesync Bot commented Jun 2, 2026

Copy link
Copy Markdown

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

@meta-codesync meta-codesync Bot closed this in 70e0382 Jun 2, 2026
@facebook-github-tools facebook-github-tools Bot added the Merged This PR has been merged. label Jun 2, 2026
@meta-codesync

meta-codesync Bot commented Jun 2, 2026

Copy link
Copy Markdown

This pull request has been merged in 70e0382.

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.

1 participant