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: npm test fails on fresh hello world create cloudflare project #7815

Closed
irvinebroque opened this issue Jan 18, 2025 · 7 comments · Fixed by #7827 or #7825
Closed

🐛 BUG: npm test fails on fresh hello world create cloudflare project #7815

irvinebroque opened this issue Jan 18, 2025 · 7 comments · Fixed by #7827 or #7825
Labels
bug Something that isn't working

Comments

@irvinebroque
Copy link
Contributor

irvinebroque commented Jan 18, 2025

Which Cloudflare product(s) does this pertain to?

C3 (npm create cloudflare), Wrangler, Workers Vitest Integration

What versions are you using?

Wrangler 3.103.2
C3 10.9.2
"@cloudflare/vitest-pool-workers": "^0.5.2",

What operating system and version are you using?

Mac latest

Please provide a link to a minimal reproduction

https://github.com/irvinebroque/vitest-breakpoint

Describe the Bug

  1. npm create cloudflare@latest
  2. Hello World + TypeScript
  3. cd project directory
  4. npm test
  5. Observe error
➜  vitest-breakpoint git:(main) npm run test

> vitest-breakpoint@0.0.0 test
> vitest


 DEV  v2.1.8 /Users/brendan/src/proj/vitest-breakpoint


⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ 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.json, `compatibility_flags` must contain one of "nodejs_compat"/"nodejs_compat_v2".
Either one of these flags is required to use `@cloudflare/vitest-pool-workers`.
 ❯ buildProjectWorkerOptions node_modules/@cloudflare/vitest-pool-workers/dist/pool/index.mjs:1270:13
 ❯ buildProjectMiniflareOptions node_modules/@cloudflare/vitest-pool-workers/dist/pool/index.mjs:1382:47
 ❯ getProjectMiniflare node_modules/@cloudflare/vitest-pool-workers/dist/pool/index.mjs:1409:21
 ❯ Object.runTests node_modules/@cloudflare/vitest-pool-workers/dist/pool/index.mjs:1683:26
 ❯ executeTests node_modules/vitest/dist/chunks/resolveConfig.RxKrDli4.js:7680:5
 ❯ node_modules/vitest/dist/chunks/cli-api.C2yC_ESk.js:10798:9
 ❯ Vitest.runFiles node_modules/vitest/dist/chunks/cli-api.C2yC_ESk.js:10820:12
 ❯ Vitest.start node_modules/vitest/dist/chunks/cli-api.C2yC_ESk.js:10662:7
 ❯ startVitest node_modules/vitest/dist/chunks/cli-api.C2yC_ESk.js:11828:7

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

 Test Files  no tests
      Tests  no tests
     Errors  1 error
   Start at  09:33:12
   Duration  407ms (transform 0ms, setup 0ms, collect 0ms, tests 0ms, environment 0ms, prepare 0ms)

refs #7388 ?

Pretty sure this is happening because npm create cloudflare@latest is not installing latest version of the vitest-pool-workers package

@irvinebroque irvinebroque added the bug Something that isn't working label Jan 18, 2025
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Jan 18, 2025
@irvinebroque
Copy link
Contributor Author

The actual version of vitest-pool-workers that is getting installed on fresh npm create cloudflare@latest is 0.5.41 rather than latest version we have published? 0.64 (link)

    "node_modules/@cloudflare/vitest-pool-workers": {
      "version": "0.5.41",

@irvinebroque
Copy link
Contributor Author

Yep everything passes soon as I pin.

@irvinebroque
Copy link
Contributor Author

I gather from #7742 that we don't automate updating dependency versions for C3 templates and can get behind.

I think if we did — then this issue possibly wouldn't have happened, since templates would already automatically start using latest published version? A good prevents?

@edmundhung
Copy link
Member

The actual version of vitest-pool-workers that is getting installed on fresh npm create cloudflare@latest is 0.5.41 rather than latest version we have published? 0.64 (link)

"node_modules/@cloudflare/vitest-pool-workers": {
  "version": "0.5.41",

This is likely because vitest-pool-workers is still on major version 0. In this case, a minor version bump is treated as a breaking change, so a version range like ^0.5.2 will only upgrade to 0.5.41 and not to 0.6 or above.

I have addressed this by bumping the version in #7827. We will need to be mindful when updating vitest-pool-workers versions until it reaches v1.

@edmundhung edmundhung moved this from Untriaged to Backlog in workers-sdk Jan 20, 2025
@edmundhung
Copy link
Member

Just discussed this with the team. Since vitest-pool-workers is still on a 0 major version, minor version bumps can include breaking changes. This explains why the templates weren't updated to the next minor version for you.

In this case, we should have updated both the compatibility_flags and the vitest-pool-workers version together. I will add some tests in #7827 to catch this in the future. 👍🏼

@vhscom
Copy link

vhscom commented Jan 21, 2025

Can confirm updating @cloudflare/vitest-pool-workers from installed version fixes the test failure.

npm ls
c3-minimal-workerd-ci-error@0.0.0 /Users/vhs/Developer/c3-minimal-workerd-ci-error
├── @cloudflare/vitest-pool-workers@0.5.41 # this version requires adding nodejs_compat flag to config
├── @cloudflare/workers-types@4.20250121.0
├── typescript@5.7.3
├── vitest@2.1.8
└── wrangler@3.103.2

Affected version of c3: create-cloudflare v2.37.1

@github-project-automation github-project-automation bot moved this from Backlog to Done in workers-sdk Jan 21, 2025
@irvinebroque
Copy link
Contributor Author

Awesome. Thanks all!

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
Projects
None yet
3 participants