Skip to content

bug: vitest and cloudflare d1 experiencing Error: internal error; reference = in latest version #10506

@rxliuli

Description

@rxliuli

What versions & operating system are you using?

System:
OS: macOS 15.6.1
CPU: (12) arm64 Apple M2 Max
Memory: 16.40 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.14.0 - /usr/local/bin/node
npm: 10.9.2 - /usr/local/bin/npm
pnpm: 10.10.0 - /usr/local/bin/pnpm
bun: 1.1.6 - ~/.bun/bin/bun

Please provide a link to a minimal reproduction

https://github.com/rxliuli/vitest-cloudflare-d1-error

Describe the Bug

When running tests containing d1, the first execution works fine, but if I modify the test file causing the tests to re-run, a mysterious Error: internal error; reference = akrfi30jdp9t7ba7rn8q225o error appears, making integration testing nearly impossible.

Vitest.D1.Error.mp4

I had to roll back the versions of vitest/@cloudflare/vitest-pool-workers/wrangler. If anyone is interested, the specific versions are:

   "@cloudflare/vitest-pool-workers": "0.8.12",
    "vitest": "3.0.9",
    "wrangler": "4.8.0"

Please provide any relevant error logs

Error: internal error; reference = akrfi30jdp9t7ba7rn8q225o
 ❯ D1DatabaseSessionAlwaysPrimary._send cloudflare-internal:d1-api:147:26
 ❯ D1DatabaseSessionAlwaysPrimary._sendOrThrow cloudflare-internal:d1-api:124:25
 ❯ D1PreparedStatement.run cloudflare-internal:d1-api:311:29
 ❯ applyD1Migrations Users/rxliuli/code/web/demo/my-first-worker-v2/node_modules/.pnpm/@cloudflare+vitest-pool-workers@0.8.68_@vitest+runner@3.2.4_@vitest+snapshot@3.2.4_vitest@3.2.4/node_modules/@cloudflare/vitest-pool-workers/dist/worker/lib/cloudflare/test-internal.mjs:32:3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions