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

Abierto
#1,963 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 5 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
66/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
php, playwright
Área
backend, testing

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
PHP
Estrellas
11.8k
Forks
559
Merge medio
5 d 23 h
PR fusionados (30 d)
24

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de pestphp/pest

Todos los issues de pestphp/pest

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.