mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
47.09k stars 9.81k forks source link

Fix the timeout logic in the `waitForEvent` integration test helper function #18325

Closed timvandermeij closed 5 days ago

timvandermeij commented 6 days ago

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.

Note that this patch gets rid of the incorrect timeout logs, but this doesn't solve the problem of the correct timeout logs yet (but it's preparatory work for follow-up patches that address that problem).

Fixes a part of #17931.

timvandermeij commented 6 days ago

/botio integrationtest

moz-tools-bot commented 6 days ago

From: Bot.io (Windows)


Received

Command cmd_integrationtest from @timvandermeij received. Current queue size: 0

Live output at: http://54.193.163.58:8877/28d99334c8f3d5e/output.txt

moz-tools-bot commented 6 days ago

From: Bot.io (Linux m4)


Received

Command cmd_integrationtest from @timvandermeij received. Current queue size: 0

Live output at: http://54.241.84.105:8877/d8e7a6b9abae7b1/output.txt

moz-tools-bot commented 6 days ago

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/d8e7a6b9abae7b1/output.txt

Total script time: 7.76 mins

moz-tools-bot commented 6 days ago

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/28d99334c8f3d5e/output.txt

Total script time: 19.12 mins