opencode-config/docs/handoff/pr-186-beforeall-output-tmp-race.md
Sergey 72caab4097
fix(draw-image): per-process output TMP in beforeAll for parallel vitest (#186)
* fix(draw-image): per-process output TMP in integration tests

* fix(draw-image): per-process output TMP in e2e tests

* fix(draw-image): per-process output TMP in cleanup test

* docs(handoff): add handoff and ADR for beforeAll output TMP fix

* docs(handoff): set PR number

* docs(handoff): set PR number 186

---------

Co-authored-by: opencode-agent <agent@opencode.local>
2026-07-31 22:39:58 +03:00

22 lines
No EOL
2.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
pr: 186
title: fix(draw-image): per-process output TMP in beforeAll for parallel vitest
---
## Что сделано
- 7 affected тест-файлов `.opencode/draw-image/tests/` переведены с общего output-каталога `/tmp/draw-image-<name>` на per-process: `TMP = path.join(os.tmpdir(), \`draw-image-<name>-\${process.pid}\`)`.
- Файлы: `render.integration.test.ts`, `render.optional.integration.test.ts`, `e2e.optional.test.ts`, `e2e.bad-input.test.ts`, `e2e.no-icon.test.ts`, `cleanup.test.ts`, `idempotency.test.ts`.
- Добавлен `import os from "node:os"` где отсутствовал (5 файлов).
- Добавлен `afterAll` с `rmSync(TMP, { recursive, force })` в 6 файлах (в `cleanup.test.ts` уже был — оставлен as-is).
- Импорт `afterAll` добавлен в vitest-импорты 6 файлов.
## Почему
При параллельном запуске 10× `npx vitest run` процессы с одинаковым набором тест-файлов конкурировали за один output-каталог: `beforeAll` процесса A удалял `TMP` (вместе с PNG + `meta.json`, только что написанными процессом B) → assertion `existsSync(outPath)` падал с `expected false to be true`, idempotency-тест падал с `expected 'skipped' to be 'rendered'`, cleanup-тест — с `unable to open for write`. `process.pid` уникален на параллельный vitest-процесс → per-process TMP устраняет race. Аналогично #177 (test helper), но для output-каталогов `beforeAll`.
## Pending
- Issue #185: тот же bug class в `tests/e2e.test.ts` (не вошёл в список #183) — отдельный PR.
## Watch out
- `e2e.test.ts` всё ещё имеет общий `/tmp/draw-image-e2e` — параллельный запуск 10× vitest падает в этом файле (4/10 запусков), фикс трекается в #185. 7 зафиксированных файлов идут зелёные во всех 10 параллельных запусках.
- Одиночный `npx vitest run`: 58/58 зелёные.
- `mkdtempSync` не использовался — `process.pid` suffixed path достаточен для внешней параллельности (отдельные процессы vitest); для intra-process threads у vitest по умолчанию forks pool, PID разный у каждого воркера.