Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnhandledPromiseRejectionWarning: Unhandled promise rejection #622

Closed
johnsonsamuel opened this issue Jan 24, 2020 · 5 comments · Fixed by #623
Closed

UnhandledPromiseRejectionWarning: Unhandled promise rejection #622

johnsonsamuel opened this issue Jan 24, 2020 · 5 comments · Fixed by #623

Comments

@johnsonsamuel
Copy link

(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.

@cbyad
Copy link

cbyad commented Jan 24, 2020

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

@JoelEinbinder
Copy link
Contributor

What version of node are you running?

@johnsonsamuel
Copy link
Author

What version of node are you running?

v8.11.2

@johnsonsamuel
Copy link
Author

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

Tried that already but no luck :/

@JoelEinbinder
Copy link
Contributor

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.

sand4rt pushed a commit to sand4rt/playwright that referenced this issue Dec 21, 2022
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants