Error details for UnhandledPromiseRejectionWarning
See original GitHub issueSteps to reproduce
Tell us about your environment:
- Puppeteer version: 1.17.0
- Platform / OS version: WSL (Bash on Windows)
- Node.js version: v12.4.0
What steps will reproduce the problem?
const clickAndWait = function(container, target, btn) {
return container.evaluate((target, btnNext) => {
return new Promise((resolve, reject) => {
let observer = new MutationObserver(function() {
observer.disconnect(); // use the mutation observer only once
resolve();
});
observer.observe(target, { childList: true, subtree: true, });
// some reasonable timeout, in case loading got stuck
setTimeout(reject.bind(this, 'timeout'), 5000);
// puppeteer click() doesn't work, must use native click() in eval
btn.click();
});
}, target, btn);
};
await ph.clickAndWait(iframe, someContainer, btnNext);
What is the expected result?
The function evaluates, MutationObserver
is set up, the button is clicked, MutationObserver
resolves the Promise and await
proceeds.
What happens instead? Error:
(node:4335) UnhandledPromiseRejectionWarning: Error: Evaluation failed: [object Object]
at ExecutionContext._evaluateInternal (/d/DATA/WDH/Webseite/workspaces/Ari/www/application/noch-frei/crawl/puppeteer-launch/node_modules/puppeteer/lib/ExecutionContext.js:122:13)
(node:4335) 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(). (rejection id: 1)
(node:4335) [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.
How to catch the Promise exception and log the Object
so I can read the error messages or at least find out what failed during the evaluation?
Also, this helper method worked in the past, after changing some of the code and moving its invocations, this error occurs.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Getting a UnhandledPromiseRejectionWarning when testing ...
The "Unhandled promise rejection" is also caused by the failed assertion, because if an error is thrown in a catch() handler, and there...
Read more >Unhandled Promise Rejections in Node.js - The Code Barbarian
Promise.reject(new Error('woops')); /* Output: $ node test.js (node:7741) UnhandledPromiseRejectionWarning: Unhandled promise rejection ...
Read more >Tracking Unhandled Promise Rejections - TrackJS
When a promise is rejected, it looks for a rejection handler. If it finds one, like in the example above, it calls the...
Read more >unhandledpromiserejectionwarni...
unhandledpromiserejectionwarning : error: request failed with status code 404 ... That or expand the error handling to display the response information.
Read more >UnhandledPromiseRejectionWar...
In Post, We discuss How To resolve UnhandledPromiseRejectionWarning: Unhandled promise rejection Error in javascript,node.js, React.js, Gatsby.js, ...
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
Indeed, we do horrible job showing some errors 🤦♂️
For example, the following doesn’t tell me why exactly evaluation has failed:
Gives me an error:
Not a single word about ReferenceError!
Whereas CDP does tell us the reason:
Anything new on that end?
I still can’t get
puppeteer
to show me browser-side errors, which is particularly inconvenient when considering puppeteer an automation tool for unit testing 😞.Other than that, thanks for this lovely tool.