Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the timeout logic in the
waitForEvent
integration test helper f…
…unction Debugging #17931, by printing all parts of the event lifecycle including timestamps, uncovered that some events for which a timeout was logged actually did get triggered correctly in the browser. Going over the code and discovering https://stackoverflow.com/questions/47107465/puppeteer-how-to-listen-to-object-events#comment117661238_65534026 showed what went wrong: if the event we wait for is triggered then `Promise.race` resolves, but that doesn't automatically cancel the timeout. The tests didn't fail on this because `Promise.race` resolved correctly, but slightly later once the timeout was reached we would see spurious log lines about timeouts for the already-triggered events. This commit fixes the issue by canceling the timeout if the event we're waiting for has triggered.
- Loading branch information