Fix flaky EventTargetDispatching-itest error handling test#57042
Closed
cortinico wants to merge 2 commits into
Closed
Fix flaky EventTargetDispatching-itest error handling test#57042cortinico wants to merge 2 commits into
EventTargetDispatching-itest error handling test#57042cortinico wants to merge 2 commits into
Conversation
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
|
@cortinico has exported this pull request. If you are a Meta employee, you can view the originating Diff in D107232191. |
|
This pull request has been merged in 70e0382. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
When
enableNativeEventTargetEventDispatchingis enabled,EventTarget.jsdefers handler errors viasetTimeout(0)inreportListenerError, making them non-deterministically visible to a synchronoustoThrowassertion (96.6% flakiness score). WhentoThrowmisses the error, it leaks as an uncaught exception into the next test ("event timestamps"), causing a cascade failure.Gate the
toThrowassertion on the legacy code path where errors propagate synchronously viarethrowCaughtError. In the new EventTarget path, dispatch the event and drain any pending errors viaFantom.runTaskto prevent test pollution. The core assertion (parentHandlercalled despite child error) runs in both paths.Changelog: [Internal]
Differential Revision: D107232191