diff --git a/packages/vitest/src/node/pools/forks.ts b/packages/vitest/src/node/pools/forks.ts index 84bdd83f930e..37c832970901 100644 --- a/packages/vitest/src/node/pools/forks.ts +++ b/packages/vitest/src/node/pools/forks.ts @@ -152,7 +152,7 @@ export function createForksPool( // Cancel pending tasks from pool when possible ctx.onCancel(() => pool.cancelPendingTasks()) - const configs = new Map() + const configs = new WeakMap() const getConfig = (project: WorkspaceProject): SerializedConfig => { if (configs.has(project)) { return configs.get(project)! @@ -165,15 +165,6 @@ export function createForksPool( return config } - const workspaceMap = new Map() - for (const spec of specs) { - const file = spec.moduleId - const project = spec.project.workspaceProject - const workspaceFiles = workspaceMap.get(file) ?? [] - workspaceFiles.push(project) - workspaceMap.set(file, workspaceFiles) - } - const singleFork = specs.filter( spec => spec.project.config.poolOptions?.forks?.singleFork, ) diff --git a/packages/vitest/src/node/pools/rpc.ts b/packages/vitest/src/node/pools/rpc.ts index 36a2b369921d..e382a1ca45f7 100644 --- a/packages/vitest/src/node/pools/rpc.ts +++ b/packages/vitest/src/node/pools/rpc.ts @@ -39,7 +39,7 @@ export function createMethodsRPC(project: WorkspaceProject, options: MethodsOpti return result } if ('id' in result && typeof result.id === 'string') { - return { id: result.id as string } + return { id: result.id } } if (code == null) { diff --git a/packages/vitest/src/node/pools/threads.ts b/packages/vitest/src/node/pools/threads.ts index 413914461712..5c7dd5024d32 100644 --- a/packages/vitest/src/node/pools/threads.ts +++ b/packages/vitest/src/node/pools/threads.ts @@ -151,7 +151,7 @@ export function createThreadsPool( // Cancel pending tasks from pool when possible ctx.onCancel(() => pool.cancelPendingTasks()) - const configs = new Map() + const configs = new WeakMap() const getConfig = (project: WorkspaceProject): SerializedConfig => { if (configs.has(project)) { return configs.get(project)! @@ -162,13 +162,6 @@ export function createThreadsPool( return config } - const workspaceMap = new Map() - for (const [project, file] of specs) { - const workspaceFiles = workspaceMap.get(file) ?? [] - workspaceFiles.push(project) - workspaceMap.set(file, workspaceFiles) - } - const singleThreads = specs.filter( spec => spec.project.config.poolOptions?.threads?.singleThread, )