jvolker / miq-nz-booking-tools

Tools to help booking a spot in New Zealand Managed Isolation and Quarantine. Automatically refreshes, checks and fills forms in the website to find and book the rare spots.
MIT License
83 stars 35 forks source link

UnhandledPromiseRejectionWarning: TimeoutError: Navigation timeout of 30000 ms exceeded #111

Open DrHaze opened 3 years ago

DrHaze commented 3 years ago

Bug

Exception raised due to timeout when loading pages. This is due to the default 30s timeout when awaiting a page. Currently living in France I'm far away from NZ and with an average internet connection. The startup of the application to the login screen takes more than 30s. This is probably the same issue as: https://github.com/jvolker/miq-nz-booking-tools/issues/107

Welcome to the MIQ Booking Assistance!
A new browser window should appear. Please navigate to "Secure your allocation" page.
(node:1092) UnhandledPromiseRejectionWarning: TimeoutError: Navigation timeout of 30000 ms exceeded
    at C:\Users\x_win\Downloads\MIQ\miq-nz-booking-tools-master\MIQ-Booking-Assistance\node_modules\puppeteer\lib\cjs\puppeteer\common\LifecycleWatcher.js:106:111
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1092) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1092) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

System

Running on Windows 10

Possible solution

To fix the issue on my side, I globally removed the navigation timeout:

        // Use current page
        const page = (await browser.pages())[0];

        await page.setDefaultNavigationTimeout(0); 
        await page.setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36');

I should probably do a merge request for that but I first started by downloading the zip of the repo and editing the file using notepad... Let me know if you want one.