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

feat: VITEST_POOL_ID cannot be the same between different running specs #1531

Merged
merged 3 commits into from Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/vitest/package.json
Expand Up @@ -88,7 +88,7 @@
"chai": "^4.3.6",
"debug": "^4.3.4",
"local-pkg": "^0.4.1",
"tinypool": "^0.1.3",
"tinypool": "^0.2.1",
"tinyspy": "^0.3.3",
"vite": "^2.9.12"
},
Expand Down
1 change: 0 additions & 1 deletion packages/vitest/src/node/pool.ts
Expand Up @@ -76,7 +76,6 @@ export function createPool(ctx: Vitest): WorkerPool {
files,
invalidates,
workerId,
poolId: !ctx.config.threads ? 1 : ((workerId - 1) % maxThreads) + 1,
}
try {
await pool.run(data, { transferList: [workerPort], name })
Expand Down
3 changes: 2 additions & 1 deletion packages/vitest/src/runtime/worker.ts
@@ -1,5 +1,6 @@
import { resolve } from 'pathe'
import { createBirpc } from 'birpc'
import { workerId as poolId } from 'tinypool'
import { ModuleCacheMap } from 'vite-node/client'
import type { ResolvedConfig, WorkerContext, WorkerRPC } from '../types'
import { distDir } from '../constants'
Expand Down Expand Up @@ -63,7 +64,7 @@ function init(ctx: WorkerContext) {
if (typeof __vitest_worker__ !== 'undefined' && ctx.config.threads && ctx.config.isolate)
throw new Error(`worker for ${ctx.files.join(',')} already initialized by ${getWorkerState().ctx.files.join(',')}. This is probably an internal bug of Vitest.`)

const { config, port, workerId, poolId } = ctx
const { config, port, workerId } = ctx

process.env.VITEST_WORKER_ID = String(workerId)
process.env.VITEST_POOL_ID = String(poolId)
Expand Down
1 change: 0 additions & 1 deletion packages/vitest/src/types/worker.ts
Expand Up @@ -9,7 +9,6 @@ import type { UserConsoleLog } from './general'

export interface WorkerContext {
workerId: number
poolId: number
port: MessagePort
config: ResolvedConfig
files: string[]
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.