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

Browser Closed : UnhandledPromiseRejectionWarning (node:1744) #5733

Closed
ianhosk opened this issue Mar 5, 2021 · 2 comments
Closed

Browser Closed : UnhandledPromiseRejectionWarning (node:1744) #5733

ianhosk opened this issue Mar 5, 2021 · 2 comments

Comments

@ianhosk
Copy link

ianhosk commented Mar 5, 2021

Context:

  • Playwright Version: 1.9.1
  • Operating System: Windows 10, wsl2 with docker
  • Node.js version: v14.16.0
  • Browser: All

Code Snippet

const { chromium } = require("playwright");
 
(async () => {
  const browser = await chromium.launch({ headless: false }); 
  const context = await browser.newContext();
  const page = await context.newPage();
  await page.goto("https://www.californiaorganics.com/");
  const dimensions = await page.evaluate(() => {
    return {
      width: document.documentElement.clientWidth,
      height: document.documentElement.clientHeight,
      deviceScaleFactor: window.devicePixelRatio
    }
  });
  console.log(dimensions);
 
  await browser.close();
})();

Describe the bug

(node:1744) UnhandledPromiseRejectionWarning: browserType.launch: Protocol error (Browser.getVersion): Browser closed.

pid=1821
[err] [1821:1821:0305/180801.614709:ERROR:browser_main_loop.cc(1386)] Unable to open X display.

pid=1821
[err] [1821:1821:0305/180801.614709:ERROR:browser_main_loop.cc(1386)] Unable to open X display.

(node:1744) 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: 2)
(node:1744) [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.

@pavelfeldman
Copy link
Member

You are running in in a headed mode (headless: false), but your WSL system does not have X display, because it is headless. you should either run Playwright on your host Windows, without WSL, or enable GUI in your WSL2.

@yury-s
Copy link
Member

yury-s commented Mar 10, 2021

Closing this issue as there has been no feedback and I see #5749 that reports the same issue but now with an x-server.

@yury-s yury-s closed this as completed Mar 10, 2021
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

No branches or pull requests

3 participants