question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

process.env.VITEST_WORKER_ID can be larger than maxThreads

See original GitHub issue

Describe the bug

We are migrating our Jest test code over to vitest. We use process.env.JEST_WORKER_ID to allocate a separate database for each worker/thread. With Jest that JEST_WORKER_ID is always between 1 and the maximum number of workers.

In vitest process.env.VITEST_WORKER_ID seems to have another meaning and is ever increasing. The documentation states that VITEST_WORKER_ID can be used to distinguish between threads. In my opinion this is not what it actually does.

Reproduction

Run any test-sutie and see that VITEST_WORKER_ID increases. In watch-mode it increases with each run.

System Info

System:
    OS: macOS 12.4
    CPU: (10) arm64 Apple M1 Max
    Memory: 1.36 GB / 64.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
    Yarn: 3.1.0 - ~/.nvm/versions/node/v16.13.1/bin/yarn
    npm: 8.10.0 - ~/.nvm/versions/node/v16.13.1/bin/npm
  Browsers:
    Chrome: 102.0.5005.115
    Firefox: 100.0.2
    Safari: 15.5
  npmPackages:
    vitest: 0.14.2 => 0.14.2

Used Package Manager

yarn

Validations

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
flunderperocommented, Jun 24, 2022

Yes, it is!

1reaction
flunderperocommented, Jun 13, 2022

Wow, that was quick! It’s ok for me that it may change. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tomcat - maxThreads vs. maxConnections - Stack Overflow
Tomcat can work in 2 modes: BIO – blocking I/O (one thread per connection); NIO – non-blocking I/O (many more connections than threads)....
Read more >
Env Variables and Modes - Vite
Vite exposes env variables on the special import.meta.env object. ... An env file for a specific mode (e.g. .env.production ) will take higher...
Read more >
Working with Environment Variables in Node.js - Twilio
First things first, we need to ensure that we have a Node.js environment. We'll then take you through the basics of setting up...
Read more >
process.env: What it is and why/when/how to use it effectively
The process.env global variable is injected by the Node at runtime ... Ultimately, if an application is not deployed, no one can use...
Read more >
Node Environment Variables: Process env Node
Node environment variables are strategies to define and consume environment-specific configurations and process env node. Learn how.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found