Skip to content

bun test hangs when running 7+ test files with @xmldom/xmldom + @svgr/core #27708

@hasesho05

Description

@hasesho05

What version of Bun is running?

1.3.5

What platform is your computer?

darwin arm64 (Apple Silicon, macOS 14.5)

What steps can reproduce the bug?

  1. Clone https://github.com/hasesho05/bun-test-hang-repro?target=https://github.com
  2. bun install
  3. bun test → hangs, never exits
  4. Each file individually passes fine: bun test tests/parse-01.test.ts

What is the expected behavior?

bun test finishes and exits.

What do you see instead?

Test output appears, but the process never terminates. CPU stays low — not a busy loop, just stuck.

Additional information

Narrowed it down to three conditions that all need to be present:

  1. At least one test file using @svgr/core (async transform)
  2. @xmldom/xmldom DOMParser called without a custom onError — so it writes [xmldom fatalError] to stderr on parse errors
  3. 7 or more test files — 6 is fine, 7 hangs every time

The stderr noise from xmldom (triggered by fast-check feeding random strings into DOMParser) seems to be the trigger when combined with the async svgr transform in a separate file.

Passing a custom onError to suppress the stderr output works around it. Migrated to vitest which runs everything in ~1.6s with no issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions