microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
65.52k stars 3.57k forks source link

[BUG] HTML Report Server EADDRINUSE (yarn v1 issue?) #11190

Closed rwoll closed 2 years ago

rwoll commented 2 years ago

Context:

System:

Repro

$ mkdir repro
$ cd repro
$ yarn create playwright
$ cat << EOF > tests/example.spec.ts
import { test, expect } from "@playwright/test";
test("example", () => expect(1).toBe(2));
test("another", async () => await new Promise(() => {}));
EOF

$ yarn playwright test --reporter html
$ # <Ctrl+C> to interrupt the tests (we have an unresolved promise to simulate a hanging test, so you need an interrupt)
$ # (you should now be looking at the HTML Report in the browser which has automatically been open)
$ # <Ctrl+C> to kill the report server as instructed int he terminal
$ # (observe the CLI process looks to have cleanly exited)

$ yarn playwright test --reporter html
$ # <Ctrl+C> to interrupt the tests (we have an unresolved promise to simulate a hanging test, so you need an interrupt)
$ # Observe the following error is thrown:
$ node:events:368
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::9323
    at Server.setupListenHandle [as _listen2] (node:net:1334:16)
    at listenInCluster (node:net:1382:12)
    at Server.listen (node:net:1469:7)
    at HttpServer.start (…/repro/node_modules/playwright-core/lib/utils/httpServer.js:85:18)
    at showHTMLReport (…/code/repro/node_modules/@playwright/test/lib/reporters/html.js:118:26)
    at HtmlReporter.onEnd (…/code/repro/node_modules/@playwright/test/lib/reporters/html.js:88:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Multiplexer.onEnd (…/code/repro/node_modules/@playwright/test/lib/reporters/multiplexer.js:77:7)
    at Runner._run (…/code/repro/node_modules/@playwright/test/lib/runner.js:397:9)
Emitted 'error' event on Server instance at:
    at emitErrorNT (node:net:1361:8)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'EADDRINUSE',
  errno: -48,
  syscall: 'listen',
  address: '::',
  port: 9323
}
^C

Describe the bug

See repro steps above. If using yarn with playwright test, the HTML Report server sometimes gets orphaned. This means subsequent uses fail. (lsof -i :9323 with a kill on the process gets you unstuck.)

rwoll commented 2 years ago

I think this is a yarn v1 issue (https://github.com/yarnpkg/yarn/issues/4667), but haven't yet confirmed that it is fixed with v2. If someone already has v2 installed, please try out the repro steps and let me know! If it's confirmed as a bug in yarn, please close this issue!

Filed so if someone else hits it, the error is searchable. Possibly relates https://github.com/microsoft/playwright/issues/10010.

D-Pagey commented 2 years ago

I had the same issue, also using yarn v1.22.15. Killing the process solved it.

aslushnikov commented 2 years ago

Thanks for filing! I'll close this in favor yarnpkg/yarn#4667

geoffreyhale commented 2 years ago

Am having same issue using npm not yarn

baptisteArno commented 2 years ago

Same issue with pnpm