playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Bug]: Worker-scoped fixture execution terminates before timeout

Open NoamGaash opened this issue 1 year ago • 2 comments

Version

1.43.1

Steps to reproduce

  1. clone my repo - git clone [email protected]:NoamGaash/never-ending-fixture.git
  2. npm install
  3. npx playwright test -g "my test"

Expected behavior

  1. I expect to see both "Fixture teardown starts" and "Fixture teardown ends" log messages
  2. I expect the string "will never be thrown" to be thrown
  3. I expect the teardown to take at least 40 seconds

Actual behavior

  1. The "Fixture teardown starts" text appears, but "Fixture teardown ends" is missing
  2. The test takes 30.2s
  3. No exception is thrown

Additional context

The documentation states that:

for slow fixtures, especially worker-scoped ones, it is convenient to have a separate timeout

That's why I believe timeouts are expected to work for worker-scoped fixtures.

Environment

System:
    OS: Linux 6.5 Ubuntu 23.10 23.10 (Mantic Minotaur)
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
    Memory: 14.82 GB / 31.01 GB
    Container: Yes
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.12.1/bin/yarn
    npm: 9.5.1 - ~/.nvm/versions/node/v18.12.1/bin/npm
  IDEs:
    VSCode: 1.88.1 - /usr/bin/code
  Languages:
    Bash: 5.2.15 - /usr/bin/bash
  npmPackages:
    @playwright/test: ^1.43.1 => 1.43.1

NoamGaash avatar Apr 24 '24 11:04 NoamGaash

Investigation note:

  • worker is stopped
  • graceful worker termination is scheduled concurrently with the worker teardown

pavelfeldman avatar Apr 24 '24 15:04 pavelfeldman

@dgozman Thank you for addressing this issue. Few words regarding our use case: In every test, we are uploading test related resources to our servers. We don't want this long operation to block the worker from proceeding the run with other tests, that's why we use fixtures to wait for this operation to be completed during worker's teardown. As a workaround, we have placed the waiting in an afterAll clause added to every test file, but performance-wise it's a terrible idea as the worker is stopped from running the next test file until the upload operation is completed. Having the ability to use worker-scope teardown could make our (and our some of our clients) test-suite twice as fast. I hope this explanation shed some light on why this issue is important for us, I'm here to help so please let me know if there's anything I can explain or do better. Thank you very much! :pray:

NoamGaash avatar Apr 29 '24 07:04 NoamGaash