[Bug]: UI mode fails with spawn EBADF on macOS when the test directory contains more than ~10k files
Los mantenedores suelen responder en 1 día
@guishiw ya está trabajando en esto.
Desde el 28/10/2026.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- macos, node.js, typescript
Línea de trabajo
Start with WorkerHost.startRunner in node_modules/playwright/lib/runner/index.js and trace how UI mode's FSWatcher and chokidar handle the test directory before worker processes are spawned. Reproduce on macOS using the supplied config, one test, and roughly 11,000 files; compare with a non-UI run. Done means UI mode runs and passes the test without spawn EBADF at that scale.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Version
1.64.1 (also reproduced on 1.63.0)
Steps to reproduce
-
Create a project with this
playwright.config.ts:import { defineConfig } from '@playwright/test'; export default defineConfig({ testDir: './', testMatch: '**/*.spec.ts', }); -
Add one trivial test,
example.spec.ts:import { expect, test } from '@playwright/test'; test('passes', () => { expect(1 + 1).toBe(2); }); -
Put 11,000 plain files under
testDir:mkdir src && for i in $(seq 0 10999); do echo "export const v$i = $i;" > src/file-$i.ts; done -
Run
npx playwright test --uiand click Run all.
Expected behavior
The test runs and passes, as it does with npx playwright test without --ui.
Actual behavior
No test runs (0/0). The output pane shows:
Error: spawn EBADF
Error: spawn EBADF
The full stack, from a real project on 1.63.0:
Error: spawn EBADF
at ChildProcess.spawn (node:internal/child_process:486:11)
at spawn (node:child_process:860:9)
at Object.fork (node:child_process:177:10)
at WorkerHost.startRunner (node_modules/playwright/lib/runner/index.js:1915:49)
at WorkerHost.start (node_modules/playwright/lib/runner/index.js:5473:23)
at Dispatcher._runJobInWorker (node_modules/playwright/lib/runner/index.js:5600:20) {
errno: -9,
code: 'EBADF',
syscall: 'spawn'
}
With 9,000 files instead of 11,000, the same project passes in UI mode.
Additional context
Cause. In UI mode, FSWatcher watches the project testDir (plus test dependencies) with the bundled chokidar. On macOS this keeps one open file descriptor per watched file. In our real project the UI-mode process held 10,658 open descriptors, about 10,600 of them regular files under testDir.
When a process holds more than macOS OPEN_MAX (10240) descriptors, the new stdio pipes for the worker get fd numbers above that limit. fork() with piped stdio then fails with EBADF. Raising ulimit -n doesn't help; ours is 1048576.
The same failure without Playwright:
// ebadf.cjs — node ebadf.cjs x 10200 → "ok"; node ebadf.cjs x 10300 → "EBADF"
const fs = require('fs');
const { fork } = require('child_process');
if (process.argv[2] === 'child') process.exit(0);
const n = Number(process.argv[3]);
for (let i = 0; i < n; i++) fs.openSync(__filename, 'r');
try {
const child = fork(__filename, ['child'], { stdio: ['ignore', 'pipe', 'pipe', 'ipc'] });
child.on('exit', () => console.log(n, 'ok'));
} catch (e) {
console.log(n, e.code);
}
So any project with more than ~10k files under testDir cannot run tests in UI mode on macOS. Non-UI runs are not affected because they don't start the watcher.
Possible fixes.
- Use a watcher that does not hold one descriptor per file on macOS, such as FSEvents or recursive
fs.watch. - Watch only the test files and their dependencies, not every file under
testDir. - Let users exclude paths from the UI-mode watcher.
Workaround. Narrow testDir so it contains fewer than ~10k files.
Environment
System:
OS: macOS 27.0.1 (26A434), arm64
Binaries:
Node: 26.12.1
npmPackages:
@playwright/test: 1.64.1 (also 1.63.0)
- Lenguaje dominante
- TypeScript
- Estrellas
- 98.5k
- Forks
- 6.7k
- Merge medio
- 17 h 15 min
- PR fusionados (30 d)
- 311
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/playwright
-
[Feature]: Node 26 Docker ImagesAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
microsoft/playwright#43759 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
microsoft/playwright#43741 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 5/100
microsoft/playwright#43831 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
[Bug]: --only-changed misses a test file when two ESM test files share an importPosiblemente ocupada @cpeaustriajc la tomó hoy. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 15/100
microsoft/playwright#43824 ·
Los mantenedores suelen responder en 1 día
-
[Feature]: Let an MCP client label its own extension tab groupPosiblemente ocupada @microsoft-playwright-automation la tomó hoy. Abiertoneeds-triage
Dificultad 4/5 3-5 días Aptitud para principiantes 15/100
microsoft/playwright#43823 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/playwright
Issues similares
-
bug low priority
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
enhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
laaielichter/Godotwright#81 ·
Los mantenedores suelen responder en 1 día
-
gebied: infra
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
VincentSmedinga/sc-heerenveen-fansite#538 ·
Los mantenedores suelen responder en 1 día
-
CI grants a token it does not need, never cancels superseded runs, and cannot fail on lint warningsAbiertogood first issue help wanted type:infrastructure type:security
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Open-Glassbeetle/glassbeetle#247 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día