question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnhandledPromiseRejectionWarning: Unhandled promise rejection

See original GitHub issue
(node:22062) 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: 55)
(node:22062) UnhandledPromiseRejectionWarning: ReferenceError: URL is not defined
    at stripFragmentFromUrl (/Users/jo20066698/Documents/playwright-project/node_modules/playwright-core/lib/network.js:63:20)
    at new Request (/Users/jo20066698/Documents/playwright-project/node_modules/playwright-core/lib/network.js:82:21)
    at new WKInterceptableRequest (/Users/jo20066698/Documents/playwright-project/node_modules/playwright-core/lib/webkit/wkInterceptableRequest.js:43:24)
    at WKPage._onRequestWillBeSent (/Users/jo20066698/Documents/playwright-project/node_modules/playwright-core/lib/webkit/wkPage.js:493:25)
    at WKSession._sessionListeners.helper_1.helper.addEventListener.e (/Users/jo20066698/Documents/playwright-project/node_modules/playwright-core/lib/webkit/wkPage.js:166:100)
    at emitOne (events.js:116:13)
    at WKSession.emit (events.js:211:7)
    at Promise.resolve.then (/Users/jo20066698/Documents/playwright-project/node_modules/playwright-core/lib/webkit/wkConnection.js:127:47)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

My code from the actual website used as reference.

const pw = require('playwright');

(async () => {
  const browser = await pw.webkit.launch(); // or 'chromium', 'firefox'
  const context = await browser.newContext();
  const page = await context.newPage();

  await page.goto('https://www.apple.com/');
  await page.screenshot({ path: 'example2.png' });

  await browser.close();
})();

Any help would be appreciated.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
JoelEinbindercommented, Jan 24, 2020

What version of node are you running?

v8.11.2

We currently support node 10 and up. If you upgrade, everything should work. Node 8 has been EOL for about a month now.

1reaction
cbyadcommented, Jan 24, 2020
try {  
  await page.goto('https://www.apple.com/');
  await page.screenshot({ path: 'example2.png' });
}
catch(e){
// do something 
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

What is an unhandled promise rejection? - Stack Overflow
Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a ...
Read more >
What is UnhandledPromiseRejectionWarning
The Promise.reject() method returns a Promise object that is rejected with a given reason. The unhandledrejection event is sent to the global scope...
Read more >
Unhandled Promise Rejection Warning - Codecademy Forums
The unhandledRejection event is emitted whenever a promise rejection is not handled. “Rejection” is the canonical term for a promise reporting ...
Read more >
Unhandled Promise Rejections in Node.js - The Code Barbarian
The node process global has an unhandledRejection event for unhandled promise rejection. Bluebird also emits this event, so if you do global.
Read more >
Node.js Process unhandledPromiseRejection Event
The unhandledRejection event is emitted whenever a promise rejection is not handled. NodeJS warns the console about ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found