Skip to content

Vitest hangs when using bun #18236

@Nick-Mazuk

Description

@Nick-Mazuk

What version of Bun is running?

1.2.5

What platform is your computer?

Darwin 23.5.0 arm64 arm

What steps can reproduce the bug?

When running vitest using bun and node is not installed on the system, vitest hangs indefinitely without any errors.

Image

I used the simplest failing test case I could think of:

import { expect, test } from 'vitest'

test('counter', () => {
    const counter = 0
    expect(counter).toBe(1)
})

Similarly, the package.json is as simple as possible:

{
    "name": "vitest-hanging-repro",
    "module": "index.ts",
    "type": "module",
    "private": true,
    "scripts": {
        "test": "vitest run"
    },
    "devDependencies": {
        "vitest": "3.0.8"
    }
}

I've tried this with and without any vite and/or vitest configuration.

Repo: https://github.com/Nick-Mazuk/vitest-hanging-repro

If you use nix, you can see that installing nodejs_22 in the flake resolves the issue.

What is the expected behavior?

Either:

  • vitest is runtime agnostic and would run successfully on bun, or
  • vitest deliberately only works in node environments and should therefore error with a warning that node is required.

What do you see instead?

Vitest hangs.

Additional information

I've tried resolving with bun run --bun test. Does not affect behavior.

Also filed vitest-dev/vitest#7681 in case this is a bug in vitest and not bun.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions