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

fix: isolate workers between envs and workspaces #3715

Merged
merged 1 commit into from Jul 11, 2023

Conversation

AriPerkkio
Copy link
Member

@AriPerkkio AriPerkkio commented Jul 2, 2023

When running files with threads enabled, make sure workers are recycled when ever environment options or workspace changes.

Also noticed that when running tests of workspace through startVitest Node API, the logger does not include project names in log entries.

@stackblitz
Copy link

stackblitz bot commented Jul 2, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@netlify
Copy link

netlify bot commented Jul 2, 2023

Deploy Preview for fastidious-cascaron-4ded94 canceled.

Name Link
🔨 Latest commit 82ea94a
🔍 Latest deploy log https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/64a64a544481fe000823592e

@AriPerkkio AriPerkkio force-pushed the fix/isolate-environments branch 3 times, most recently from 47fc512 to d417344 Compare July 6, 2023 04:32
@AriPerkkio AriPerkkio marked this pull request as ready for review July 6, 2023 05:16
Comment on lines +167 to +170
// Once all tasks are running or finished, recycle worker for isolation.
// On-going workers will run in the previous environment.
await new Promise<void>(resolve => pool.queueSize === 0 ? resolve() : pool.once('drain', resolve))
await pool.recycleWorkers()
Copy link
Member Author

@AriPerkkio AriPerkkio Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To summarize this:

  • Pool's queue is filled with tasks that have same options (env, workspace)
  • When pool takes the last task from queue, we tell pool to recycle all workers and fill queue with tasks that have new options
  • The earlier tasks will run and recycle once they finish
  • New tasks in the queue will use fresh workers

This guarantees that tasks with different options are run parallel.

@sheremet-va sheremet-va merged commit ed4e042 into vitest-dev:main Jul 11, 2023
18 checks passed
@AriPerkkio AriPerkkio deleted the fix/isolate-environments branch July 11, 2023 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tests using different environments should always be isolated
2 participants