Browser plugin: a second Pest process deletes a running parallel run's playwright-server.json

Đang mở
#1,963 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 5 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
66/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php, playwright
Lĩnh vực
backend, testing

Hướng nghiên cứu

Start with Plugin::terminate(), ServerManager::instance()->playwright()->stop(), PlaywrightNpmServer::stop(), and AlreadyStartedPlaywrightServer::markAsStopped() and fromPersisted(). Trace when the server address is persisted and when another Pest process removes it; reproduce with a parallel browser run and a second Pest process. Done when the second process can exit without removing the running run's server file, and the parallel browser tests continue to pass.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug
Pest Version

5.1.1 (pest-plugin-browser 5.0.1)

PHP Version

8.4.23

Operation System

macOS

Description

When a parallel run (--parallel) is using the browser plugin, the parent process starts one Playwright server and writes its address to vendor/pestphp/pest-plugin-browser/.temp/playwright-server.json, which the workers read through AlreadyStartedPlaywrightServer::fromPersisted().

Plugin::terminate() calls ServerManager::instance()->playwright()->stop() in every non-worker process. That ends in PlaywrightNpmServer::stop(), which calls AlreadyStartedPlaywrightServer::markAsStopped() and unlinks the file unconditionally, even when the process never started a server.

So any other Pest process started in the same project while a parallel run is in progress deletes the file when it ends, and every remaining browser test of the parallel run fails with:

file_get_contents(.../vendor/pestphp/pest-plugin-browser/.temp/playwright-server.json): Failed to open stream: No such file or directory

This includes a second process that ends immediately without running any test, for example one that exits from the configured bootstrap file.

Steps to reproduce
  1. Run a suite with browser tests in parallel: ./vendor/bin/pest --parallel.
  2. While it runs, run any other Pest command in the same project, for example ./vendor/bin/pest tests/Unit/ExampleTest.php.
  3. Every browser test of the first run that starts after step 2 finishes fails with the error above.
Expected

markAsStopped() (or stop()) only removes the persisted file when this process started the server that wrote it, for example by keeping track of whether persist() was called in this process.

Ngôn ngữ chính
PHP
Star
11.8k
Fork
559
Merge trung bình
5 ngày 23 giờ
Pull request đã merge (30 ngày)
24

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của pestphp/pest

Tất cả issue của pestphp/pest

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.