Skip to content

Vitest pool drops miniflare.unsafeDevRegistryPath #14676

Description

@matthew-gizmo

Which Cloudflare product(s) does this pertain to?

Workers Vitest integration (@cloudflare/vitest-pool-workers)

Versions

  • @cloudflare/vitest-pool-workers: 0.18.4
  • wrangler: 4.110.0
  • bundled miniflare: 4.20260708.1
  • vitest: 4.1.8
  • Node.js: 24.18.0

What is the problem?

cloudflareTest() accepts miniflare.unsafeDevRegistryPath, but the pool drops that option before constructing the project Miniflare instance. A service binding intended to resolve a separately running local Worker through Wrangler's dev registry therefore cannot resolve.

Minimal configuration shape:

cloudflareTest({
  remoteBindings: false,
  wrangler: {
    configPath: './wrangler.jsonc',
    environment: undefined
  },
  miniflare: {
    unsafeDevRegistryPath: registryPath,
    serviceBindings: {
      AI_SERVICE: 'ai'
    }
  }
});

With a local Worker named ai registered in registryPath, the test Worker fails to start:

Worker "core:user:vitest-pool-workers-runner-"'s binding "AI_SERVICE"
refers to a service "core:user:ai", but no such service is defined.

If the option is manually forwarded by the pool, Miniflare instead creates the dev-registry proxy and resolves the binding through the configured registry as expected.

Root cause

parseCustomPoolOptions() parses the Miniflare options, but buildProjectMiniflareOptions() builds a new object from SHARED_MINIFLARE_OPTIONS and selected pool fields. unsafeDevRegistryPath is not preserved or forwarded.

Proposed fix

Preserve options.miniflare.unsafeDevRegistryPath during custom option parsing and include it in the object returned by buildProjectMiniflareOptions(). The pool's internal WorkersPoolOptionsWithDefines type also needs to carry the option.

Conceptually:

const unsafeDevRegistryPath = options.miniflare.unsafeDevRegistryPath;
// ...
options.unsafeDevRegistryPath = unsafeDevRegistryPath;

return {
  ...SHARED_MINIFLARE_OPTIONS,
  ...(customOptions.unsafeDevRegistryPath === undefined
    ? {}
    : { unsafeDevRegistryPath: customOptions.unsafeDevRegistryPath }),
  // ...
};

I can prepare an upstream PR if this is an accepted supported use of the Vitest pool.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Untriaged

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions