cloudflare / cloudflare/workers-sdk

🐛 BUG: Yarn PnP Compatibility Error with @cloudflare/vitest-pool-workers

Open
#7,157 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.5k
Forks
1.5k
Avg merge
3d 8h
Merged PRs (30d)
187

Description

### Which Cloudflare product(s) does this pertain to?

Workers Vitest Integration

### What version(s) of the tool(s) are you using?

3.84.1 [Wrangler], 2.1.4 [Vitest], 0.5.24 [@cloudflare/vitest-pool-workers], 4.5.1 [yarn], 5.6.3 [typescript]

### What version of Node are you using?

20.11.1

### What operating system and version are you using?

macOS Sequoia 15.1 (24B83)

### Describe the Bug

### Bug Description:
When using **Yarn Plug'n'Play** (PnP) with `@cloudflare/vitest-pool-workers`, the test command fails with module resolution errors that prevent loading `@cloudflare/vitest-pool-workers`. Setting up testing results in an "Error: Failed to load URL" message due to incompatible module resolution handling.

The error is displayed when running `yarn vitest run`:
```plaintext
Error: Failed to load url /path/to/project/@cloudflare/vitest-pool-workers (resolved id: /path/to/project/@cloudflare/vitest-pool-workers). Does the file exist?
```

### Expected Behavior:
Expected `@cloudflare/vitest-pool-workers` to work seamlessly under Yarn's PnP configuration without needing adjustments to Yarn’s `nodeLinker`.

### Temporary Workaround:
Switching the `nodeLinker` setting in `.yarnrc.yml` to either `'pnpm'` or `'node-modules'` resolves the issue, but this circumvents the intended PnP functionality.

### Please provide a link to a minimal reproduction

https://github.com/ZL-Asica/KumoAuth

### Please provide any relevant error logs

```bash
❯ yarn vitest run

RUN v2.1.4 /Users/xxx

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: Failed to load url /Users/xxx/@cloudflare/vitest-pool-workers (resolved id: /Users/xxx/@cloudflare/vitest-pool-workers). Does the file exist?
❯ loadAndTransform .yarn/__virtual__/vite-virtual-831acd9201/5/.yarn/berry/cache/vite-npm-5.4.10-30d2e3a4e2-10c0.zip/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:51920:17

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { code: 'ERR_LOAD_URL' }
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

Test Files no tests
Tests no tests
Errors 1 error
Start at 12:48:48
Duration 25ms (transform 0ms, setup 0ms, collect 0ms, tests 0ms, environment 0ms, prepare 0ms)
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure in the linked KumoAuth minimal reproduction with Yarn Plug'n'Play by running `yarn vitest run`. Start with the `@cloudflare/vitest-pool-workers` setup and `.yarnrc.yml`, then trace the reported module-resolution error. Done means the test command loads the package successfully while retaining the PnP node linker.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.