Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: Compatibility Issue: nodejs_compat_v2 Flag Causes Errors with Vitest Integration @cloudflare/vitest-pool-workers #7156

Closed
ZL-Asica opened this issue Nov 2, 2024 · 0 comments · Fixed by #7278
Assignees
Labels
bug Something that isn't working vitest Relating to the Workers Vitest integration

Comments

@ZL-Asica
Copy link

ZL-Asica commented Nov 2, 2024

Which Cloudflare product(s) does this pertain to?

Wrangler, 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

Describe the Bug

According to Cloudflare's documentation on Node.js compatibility (link), setting the compatibility flag to nodejs_compat_v2 should enable compatibility behavior equivalent to nodejs_compat as long as the compatibility date is September 23, 2024, or later. However, using nodejs_compat_v2 results in compatibility issues with Vitest integration in my project, causing the following error during testing:

Error Log

Error: In project vitest.config.mts's configuration file wrangler.toml, `compatibility_flags` must contain "nodejs_compat".
This flag is required to use `@cloudflare/vitest-pool-workers`.
 ❯ assertCompatibilityFlagEnabled ...

Observed Behavior

When using nodejs_compat_v2, Vitest testing fails with a compatibility_flags error indicating that nodejs_compat is required. Switching back to nodejs_compat resolves this error, but it contradicts the expected functionality stated in the documentation.

Expected Behavior

With nodejs_compat_v2 set as the compatibility flag, tests should pass successfully without requiring nodejs_compat.

Steps to Reproduce

  1. Set compatibility flag to nodejs_compat_v2 in wrangler.toml with a compatibility date after September 23, 2024.
  2. Run tests using @cloudflare/vitest-pool-workers.
  3. Observe the compatibility error.

This issue seems to be tied to the interaction between nodejs_compat_v2 and Vitest's Cloudflare integration package.

Please provide a link to a minimal reproduction

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

Please provide any relevant error logs

Using vars defined in .dev.vars

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ 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: In project vitest.config.mts's configuration file wrangler.toml, `compatibility_flags` must contain "nodejs_compat".
This flag is required to use `@cloudflare/vitest-pool-workers`.
 ❯ assertCompatibilityFlagEnabled node_modules/.store/@cloudflare-vitest-pool-workers-virtual-36b606629f/package/dist/pool/index.mjs:1155:11
 ❯ buildProjectWorkerOptions node_modules/.store/@cloudflare-vitest-pool-workers-virtual-36b606629f/package/dist/pool/index.mjs:1178:3
 ❯ buildProjectMiniflareOptions node_modules/.store/@cloudflare-vitest-pool-workers-virtual-36b606629f/package/dist/pool/index.mjs:1294:47
 ❯ getProjectMiniflare node_modules/.store/@cloudflare-vitest-pool-workers-virtual-36b606629f/package/dist/pool/index.mjs:1321:21
 ❯ Object.runTests node_modules/.store/@cloudflare-vitest-pool-workers-virtual-36b606629f/package/dist/pool/index.mjs:1595:26
 ❯ executeTests node_modules/.store/vitest-virtual-7eb2413551/package/dist/chunks/resolveConfig.DPmbhVlP.js:7678:5
 ❯ node_modules/.store/vitest-virtual-7eb2413551/package/dist/chunks/cli-api.CKrRYkw8.js:10800:9
 ❯ Vitest.runFiles node_modules/.store/vitest-virtual-7eb2413551/package/dist/chunks/cli-api.CKrRYkw8.js:10820:12
 ❯ Vitest.start node_modules/.store/vitest-virtual-7eb2413551/package/dist/chunks/cli-api.CKrRYkw8.js:10663:7

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 Test Files  no tests
      Tests  no tests
     Errors  1 error
   Start at  13:19:48
   Duration  435ms (transform 0ms, setup 0ms, collect 0ms, tests 0ms, environment 0ms, prepare 0ms)


 FAIL  Tests failed. Watching for file changes...
       press h to show help, press q to quit
[vpw:dbg] Shutting down runtimes...
@ZL-Asica ZL-Asica added the bug Something that isn't working label Nov 2, 2024
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Nov 2, 2024
@andyjessop andyjessop moved this from Untriaged to Backlog in workers-sdk Nov 15, 2024
@andyjessop andyjessop self-assigned this Nov 15, 2024
@andyjessop andyjessop added the vitest Relating to the Workers Vitest integration label Nov 19, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in workers-sdk Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working vitest Relating to the Workers Vitest integration
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants