playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[BUG] UnhandledPromiseRejectionWarning: Error: by Firefox and web kit.

Open abhayp5 opened this issue 6 years ago • 13 comments

Context:

  • Playwright Version: "playwright": "^1.0.2"
  • Operating System: [e.g. Windows 10]
  • Node version: [e.g. 12.17.0]
  • Browser: [Firefox, WebKit]
  • Extra: [any specific details about your environment]

Code Snippet

Help us help you! Put down a short code snippet that illustrates your bug and that we can run and debug locally. For example:

const playwright = require('playwright');

(async() =>{
 
    const browser = await playwright.firefox.launch({headless:false});
    const context = await browser.newContext();
    const page = await context.newPage();
    await page.goto("www.amazon.com");
})();

Describe the bug After installing node and npm i playwright and running the file using command "node ./filename.js" The firefox launches for few milli sec but throws below mentioned error. And then firefox.exe goes missing from \AppData\Local\ms-playwright\firefox-1089\firefox folder.

D:\Abhay\code\test>node TestAd.js
(node:3244) UnhandledPromiseRejectionWarning: Error: Navigation failed because b
rowser has disconnected! while navigating to http://www.amazon.com while navigating to http://www.amazon.com
    at D:\Abhay\code\node_modules\playwright-core\lib\frames.js:865:71
  -- ASYNC --
    at Frame.<anonymous> (D:\Abhay\code\node_modules\playwright-core\lib\
helper.js:63:23)
    at Page.goto (D:\Abhay\code\node_modules\playwright-core\lib\page.js:
192:33)
    at Page.<anonymous> (D:\Abhay\code\node_modules\playwright-core\lib\h
elper.js:64:31)
    at D:\Abhay\code\test\TestAd.js:20:16
(node:3244) 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 termina
te the node process on unhandled promise rejection, use the CLI flag `--unhandle
d-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejectio
ns_mode). (rejection id: 1)
(node:3244) [DEP0018] DeprecationWarning: Unhandled promise rejections are depre
cated. In the future, promise rejections that are not handled will terminate the
 Node.js process with a non-zero exit code.

abhayp5 avatar May 29 '20 18:05 abhayp5

In second attempt of running the same test using node ./Test.js

(node:896) UnhandledPromiseRejectionWarning: Error: Failed to launch browser: E ror: spawn C:\Users\Abhay\AppData\Local\ms-playwright\firefox-1089\firefo \firefox.exe ENOENT at ChildProcess. (D:\Abhay\code\node_modules\playwright-c re\lib\server\processLauncher.js:56:20) at Object.onceWrapper (events.js:422:26) at ChildProcess.emit (events.js:315:20) at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12) at onErrorNT (internal/child_process.js:469:16) at processTicksAndRejections (internal/process/task_queues.js:84:21) (node:896) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This rror originated either by throwing inside of an async function without a catch lock, or by rejecting a promise which was not handled with .catch(). To termina e the node process on unhandled promise rejection, use the CLI flag --unhandle -rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejectio s_mode). (rejection id: 1) (node:896) [DEP0018] DeprecationWarning: Unhandled promise rejections are depre ated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

abhayp5 avatar May 29 '20 19:05 abhayp5

Facing Same error as there is no firefox file in the folder

pooja-genpact avatar Jun 03 '20 18:06 pooja-genpact

@pooja-genpact - Was Firefox downloaded during npm install playwright? Are you able to use the other browsers (chromium, webkit)?

@abhay5 - I'm a bit lost on how firefox.exe was removed from the directory. Can you share more on your setup - what version of Node? Is this npm/yarn? How are you running the script? Also, are you able to use the other browsers (chromium, webkit)?

arjunattam avatar Jun 04 '20 04:06 arjunattam

@pooja-genpact - Was Firefox downloaded during npm install playwright? Are you able to use the other browsers (chromium, webkit)?

Chromium is working fine but npm install playwright doesn't install firefox and webkit in APPDATA folder. I tries npm install playwright-firefox. It create folder in node-module folder but doesnot download binaries in common location. Please help with the command to download binaries

pooja-genpact avatar Jun 04 '20 07:06 pooja-genpact

Thanks @pooja-genpact. Can you please share the output logs when you run npm install playwright-firefox?

arjunattam avatar Jun 04 '20 17:06 arjunattam

Please reopen if the issue persists.

dgozman avatar Aug 14 '20 22:08 dgozman

Hi Guys, I've reproduced the same exception with the following packages versions:

Playwright Version: "playwright": "^1.3.0" Operating System: [Windows 10] Node version: [v12.18.3] Browser: [Firefox, Chromium]

//Code const { chromium, firefox } = require('playwright');

(async () => {

//browser in context  
const browser = await chromium.launch();
const context = await browser.newContext();

//page
const page = await context.newPage();

//navigate to page
page.goto("https://www.google.com/");

//Close browser
await browser.close();

})();

Still need to reopen or create a new one?

dneprokos avatar Aug 20 '20 10:08 dneprokos

@dneprokos Could you please paste the full exception text here? There are many possible reasons for UnhandledPromiseRejectionWarning, so we have to know the exact details.

dgozman avatar Aug 20 '20 17:08 dgozman

Hi @dgozman , I'm also facing same issue when using chrome browser and below is the exception text, my node version is v12.16.1

Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs. at ProgressController.run (/Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/node_modules/playwright/lib/progress.js:73:30) at runNavigationTask (/Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/node_modules/playwright/lib/frames.js:961:23) at Frame.goto (/Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/node_modules/playwright/lib/frames.js:284:16) at Frame.goto (/Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/node_modules/playwright/lib/helper.js:79:31) at /Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/node_modules/playwright/lib/page.js:203:61 at Page._attributeToPage (/Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/node_modules/playwright/lib/page.js:356:20) at Page.goto (/Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/node_modules/playwright/lib/page.js:203:21) at Page.goto (/Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/node_modules/playwright/lib/helper.js:79:31) at /Users/seaswara/Documents/ToStudy/Playwright/SampleFramework/src/firstTest.js:12:16 (node:91754) 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: 1) (node:91754) [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.

saranyaeaswaran avatar Aug 25 '20 06:08 saranyaeaswaran

@saranyaeaswaran There should also be a specific error message before the Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs.. Could you please paste that?

dgozman avatar Aug 26 '20 02:08 dgozman

@dneprokos Could you please paste the full exception text here? There are many possible reasons for UnhandledPromiseRejectionWarning, so we have to know the exact details.

@dgozman Sorry, just saw your message. That's all I have after running 'node loginPageTests.js' command. At least in console. Please tell me if you need some more information. Thanks.

(node:27572) UnhandledPromiseRejectionWarning: Error: page.goto: Navigation failed because page was closed! =========================== logs =========================== [api] navigating to "https://www.google.com/", waiting until "load"

Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs. at C:\TestProjects\TestPlaywriteTests\node_modules\playwright\lib\frames.js:927:59 -- ASYNC -- at Frame.goto (C:\TestProjects\TestPlaywriteTests\node_modules\playwright\lib\helper.js:79:23) at C:\TestProjects\TestPlaywriteTests\node_modules\playwright\lib\page.js:208:61 at Page._attributeToPage (C:\TestProjects\TestPlaywriteTests\node_modules\playwright\lib\page.js:370:20) at Page.goto (C:\TestProjects\TestPlaywriteTests\node_modules\playwright\lib\page.js:208:21) at Page.goto (C:\TestProjects\TestPlaywriteTests\node_modules\playwright\lib\helper.js:80:31) at C:\TestProjects\TestPlaywriteTests\tests\loginPageTests.js:13:10 (node:27572) 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: 1) (node:27572) [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.

dneprokos avatar Aug 26 '20 13:08 dneprokos

@dneprokos Thank you for the details. Unfortunately, this does not tell me much - the navigation did not even start, but no idea why. Could you try to run with DEBUG=pw:protocol,pw:api environment variable and share the (large) output it produces? Note that it contains sensitive bits like cookies, so please do not share unless you are comfortable. You can send it to [email protected] instead of sharing.

dgozman avatar Aug 26 '20 16:08 dgozman

Closing since we cannot reproduce the issue.

dgozman avatar Nov 24 '20 18:11 dgozman