Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

musicVideoSceneHooks test can leak its temp root past afterAll and fail the suite's temp-leak guard

Closed
#12,883 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@atomantic is already working on this.

Since Oct 22, 2026.

  • #12888 by @atomantic — merged

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript
Domain
testing

Research direction

Start with server/services/musicVideoSceneHooks.test.js and inspect its afterAll teardown, the event listeners, and the hook writes to music-video-projects.json. Trace how pending writes can be awaited, then run the file under 4 concurrent workers repeatedly and check for leaked mv-scene-hooks-test- entries. Done when 50 consecutive runs and the full server suite's temp-leak guard report no leak, with no assertions loosened.

Written by the indexing model from the issue text.

Description

bug effort:medium model:light plan planner:sonnet-5-5 tests

Problem

server/services/musicVideoSceneHooks.test.js can leave its temp data root behind, and the run-wide temp-leak guard then fails the whole server suite even though every test passed:

⚠️ test temp leak: mv-scene-hooks-test- ×1
❌ test temp leak guard: failing the run with exit code 1 for 1 leaked entry under the run temp root

Evidence: observed once in two full local server runs (CI runner script, PORTOS_PREGATE_MAX_WORKERS=4, loaded machine). It did not recur in the second full run, nor in 7 isolated runs of the file (3 serial, 4 concurrent), so this is a suspected load-sensitive race, not a reproduced cause.

The file creates TEST_DATA_ROOT = mkdtempSync(join(tmpdir(), 'mv-scene-hooks-test-')) at import time and removes it in a single afterAll(() => rmSync(TEST_DATA_ROOT, { recursive: true, force: true })). The test's own comment says a hook "still settling from the previous test can emit after this test's listeners attach" — the same late completion can write the project store (music-video-projects.json, created by the atomic writer with its parent directories) after afterAll has already removed the root, which recreates the directory and leaks it. The earlier flake fix (#11839) addressed the sibling symptom (a take landing late) but not the teardown ordering.

Found while validating #12850; not caused by it (the change only moves log streams).

Decision

  1. In afterAll, quiesce before removing: detach the mediaJobEvents / musicVideoEvents listeners, then wait for the in-flight hook writes to settle (poll the project store until its mtime/contents stop changing, or expose and await the hook's pending-write promise if one exists), then rmSync.
  2. Remove the root a second time on a short retry if a late write recreated it, so a straggler cannot survive the file.
  3. Do not widen the guard or add the prefix to any allowlist.

Acceptance criteria

  • 50 consecutive runs of the file under 4 concurrent workers leave no mv-scene-hooks-test- entry.
  • The full server suite's temp-leak guard reports nothing for this file.
  • No assertion in the file is loosened.

Related to #12850. Dispatch rationale: model:light — a teardown-ordering fix in one test file; effort:medium because the race has to be provoked before the fix can be trusted.

Dominant language
JavaScript
Stars
38
Forks
32
Avg merge
36m
Merged PRs (30d)
989

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from atomantic/PortOS

All issues in atomantic/PortOS

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.