Skip to content

docgen: intra-process test hang when two analyzeAllParallel tests share a node process #3

Description

@decider

Summary

docgen/docgen.test.mjs has a test-isolation hang: two async tests that exercise analyzeAllParallel

  • analyzeAllParallel completes every dir with parallel=4 — no state races
  • analyzeAllParallel keeps bottom-up ordering: trunk waits for leaves

each pass in isolation but when they run in the same node process (the normal node --test docgen.test.mjs invocation), one leaves state that stalls the next, and the file never exits (file-level timeout → cancelled).

Reproduce

cd docgen
# Hangs (file-level timeout):
node --test --test-timeout=60000 docgen.test.mjs

# Each passes alone:
node --test --test-name-pattern="completes every dir with parallel=4" docgen.test.mjs
node --test --test-name-pattern="bottom-up ordering" docgen.test.mjs

What's been ruled out

  • Filesystem bleed — each test uses its own mkdtemp root with rmSync cleanup; no shared paths or chdir.
  • _saveChain module global — added resetSaveChain() at the top of analyzeAllParallel and made saveStateMerging isolate per-call failures (so a thrown save can't poison the chain). Did not fix the hang, so the chain isn't the (sole) cause.
  • Skipping one of the two tests just moves the hang to the next analyzeAllParallel test → the contamination flows from the parallel run, not a specific victim.

Likely area

Some async resource from the parallel=4 run (a pending promise / unsettled setTimeout in the mock-runner path, or an abandoned in-flight analyzeOne after a batch returns) survives into the next test's event loop. Needs a why-is-node-running / async-hooks trace to pin down.

Current mitigation (not a fix)

CI gates on the two clean docgen suites (inject-readme-context.test.mjs, install-push-hook.test.mjs) and runs docgen.test.mjs non-blocking (continue-on-error) so the hang surfaces in logs without red-gating the pipeline.

Note

The tool is unaffected — docgen generates real repos (incl. this one) with --parallel N without hanging. This is purely a test-harness isolation issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions