Skip to content

Bug Report - Segmentation fault on MacOS with workerd and wrangler and vitest #6583

Open

Description

@paralin

I am seeing a segfault crash in the Cloudflare Vitest worker pool on macOS arm64.

  • macOS 15.7.3 (24G419)
  • Apple Silicon
  • bun 1.3.12
  • node v25.9.0
  • vitest 4.1.4
  • @cloudflare/vitest-pool-workers 0.14.6
  • wrangler 4.82.2

Some tests run, but tests that import certain Worker/Durable Object modules crash before any test body executes.

*** Received signal #11: Segmentation fault: 11

Error: [vitest-pool]: Worker cloudflare-pool emitted error.
Caused by: Error: Worker exited unexpectedly

What works

A simple non-DO test file passes under the same runner config.

What fails

Files that import more substantial Worker/Durable Object code paths consistently crash the Cloudflare pool before tests run.

Reproduction commands

These both fail the same way:

bunx vitest run --max-workers=1 --no-isolate path/to/crashing.test.ts
node ./node_modules/vitest/vitest.mjs run --max-workers=1 --no-isolate path/to/crashing.test.ts

The repo script also fails:

bun run test

Important notes

  • This is not Bun-specific. Reproduces with direct node invocation too.
  • --max-workers=1 --no-isolate does not avoid the crash.
  • The crash happens before test execution for the affected files.

Tried

I also tried forcing Miniflare to use a newer external workerd binary from the latest GitHub release:

MINIFLARE_WORKERD_PATH=/absolute/path/to/workerd \
  bunx vitest run --max-workers=1 --no-isolate path/to/crashing.test.ts

The result was unchanged: same cloudflare-pool worker crash and segfault.

I tested with:

  • external workerd binary version: workerd 2026-04-14

Activity

  1. paralin commented on Apr 15, 2026

    @paralin
    Author

    Repro repo: https://github.com/paralin/workerd-issue-6583

    Commands

    Passing control test:

    bunx vitest run --max-workers=1 --no-isolate src/control.test.ts

    Crashing repro:

    bun run test:sqlite

    Equivalent direct command:

    bunx vitest run --max-workers=1 --no-isolate src/node-sqlite.test.ts

    Expected

    The node:sqlite test should pass and report one successful test.

    Actual

    The Cloudflare pool worker exits before any test executes:

    *** Received signal #11: Segmentation fault: 11
    Error: [vitest-pool]: Worker cloudflare-pool emitted error.
    Caused by: Error: Worker exited unexpectedly
    
    Test Files   (1)
         Tests  no tests
        Errors  1 error
    

    Minimal crashing test

    import { describe, expect, it } from 'vitest'
    import { DatabaseSync } from 'node:sqlite'
    
    describe('node:sqlite under cloudflare vitest pool', () => {
      it('opens an in-memory database', () => {
        const db = new DatabaseSync(':memory:')
        db.exec('CREATE TABLE t (id INTEGER PRIMARY KEY, name TEXT NOT NULL)')
        db.exec("INSERT INTO t (name) VALUES ('ok')")
        const row = db.prepare('SELECT name FROM t').get() as { name: string }
        expect(row.name).toBe('ok')
      })
    })

    Additional checks

    • This is not Bun-specific. The broader crash also reproduces when invoking
      Vitest via node ./node_modules/vitest/vitest.mjs ....
    • Pointing Miniflare at a locally built workerd binary did not change the
      behavior.

    Example:

    MINIFLARE_WORKERD_PATH=/absolute/path/to/workerd \
      bun run test:sqlite

    still crashes with the same worker-pool error and segfault.

    Native trace from source-built workerd

    I attached LLDB to the spawned workerd process and reproduced the crash using
    a local source build. The process stopped with:

    EXC_BAD_ACCESS (code=2, address=0x16a6f3fe0)
    

    Top of stack:

    libc++abi.dylib`operator new
    workerd`kj::_::HeapArrayDisposer::allocateImpl
    workerd`kj::heapString(char const*, unsigned long)
    workerd`kj::heapString(kj::ArrayPtr<char const>)
    workerd`kj::Path::evalPart
    workerd`kj::Path::evalImpl
    workerd`kj::PathPtr::eval
    workerd`workerd::jsg::ModuleRegistryImpl<...>::resolve
    workerd`workerd::jsg::ModuleRegistryImpl<...>::resolve
    workerd`workerd::jsg::ModuleRegistryImpl<...>::resolve
        ...
    

    The resolve(...) frame repeats deeply, which makes this look like a module
    resolution/path evaluation problem inside workerd, triggered by the
    node:sqlite import path under the Vitest pool.

  2. cenkce commented on May 14, 2026

    @cenkce

    Hi is there a quick workaround? I am stuck with this error.

  3. cenkce commented on May 14, 2026

    @cenkce

    I downgraded vitest@3.x and @cloudflare/vitest-pool-workers: ~0.12.0. now It works. But if I upgraded vitest version to ^4.1.0 and @cloudflare/vitest-pool-workers above ^0.13.x It starts failing.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions