Skip to content

Commit

Permalink
feat: VITEST_POOL_ID cannot be the same between different running spe…
Browse files Browse the repository at this point in the history
…cs (#1531)

* feat: VITEST_POOL_ID cannot be the same between different running specs

* chore: allow tinypool as ^0.2.0

* chore: update tinypool
  • Loading branch information
sheremet-va committed Jun 24, 2022
1 parent 3c9ba89 commit d9c96fa
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
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.

0 comments on commit d9c96fa

Please sign in to comment.