UnhandledPromiseRejectionWarning on Navigation Timeout Exceeded
See original GitHub issueSteps to reproduce
Environment:
- Puppeteer version: 1.3.0
- Platform / OS version: macOS 10.13.1
- Node.js version: 8.9.4
Steps
Below is the code producing this problem:
try {
...
await page.waitForNavigation({waitUntil: 'networkidle2'})
...
} catch (err) {
// Throw an error.
throwError(err, page, browser, res)
}
throwError = (async (err, page, browser, res) => {
// Log the error.
console.log(err)
// Close the browser.
await page.close()
await browser.close()
// Return an error response message.
res.json({code: 'ERROR', message: 'An unexpected error has occurred.'})
})
When a request times out, I get the following error:
Error: Navigation Timeout Exceeded: 30000ms exceeded
at Promise.then (node_modules/puppeteer/lib/NavigatorWatcher.js:73:21)
at <anonymous>
(node:72563) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Protocol error (Runtime.callFunctionOn): Target closed.
(node:72563) [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.
What is the expected result?
The page and browser should get closed without throwing an exception/error.
What happens instead?
Error: Protocol error (Runtime.callFunctionOn): Target closed.
is displayed instead of the page and browser getting closed gracefully. Timeout Exceeded error is understandable and is correct.
I want to understand why Error: Protocol error (Runtime.callFunctionOn): Target closed.
is being thrown and how we can avoid it?
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Puppeteer throws "UnhandledPromiseRejectionWarning ...
I changed "example.com" because works fine and trying with other sites, but with "github.com" script returns an timeout exception in the await ...
Read more >How to solve Puppeteer TimeoutError: Navigation timeout of ...
To solve this problem, you will have 2 options, either to increase this timeout in the configuration or remove it at all. Personally,...
Read more >Fix: navigation timeout of 30000 ms exceeded in puppeteer?
In this video, I am going to show you how we can fix navigation timeout of 30000 ms exceeded in puppeteer.You will generally...
Read more >Fix: navigation timeout of 30000 ms exceeded in puppeteer?
r/node - Why is the function that uses stream taking longer?
Read more >navigation timeout of 30000 ms exceeded, puppeteer console
The main type of error that's encountered is a timeout. The issue is that there's no documented way to distinguish the type of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Aetheryx Thanks, I see what’s going on here. That’s somewhat related to #1454; as a workaround, I’d recommend navigating until
domcontentloaded
event:‘load’ worked for me:
await page.goto('http://example.com', {waitUntil: 'load'});