{"id":"9963778bc891c69f","repo":"vitest-dev/vitest","slug":"isolated-tasks-should-not-share-runners","errorCode":null,"errorMessage":"Isolated tasks should not share runners","messagePattern":"Isolated tasks should not share runners","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/pools/pool.ts","lineNumber":317,"sourceCode":"    promise,\n    resolve,\n    reject: (reason: unknown) => {\n      resolver.isRejected = true\n      reject(reason)\n    },\n    isRejected: false,\n  }\n\n  return resolver\n}\n\nfunction formatFiles(task: PoolTask) {\n  return task.context.files.map(file => file.filepath).join(', ')\n}\n\nfunction isEqualRunner(runner: PoolRunner, task: PoolTask) {\n  if (task.isolate) {\n    throw new Error('Isolated tasks should not share runners')\n  }\n  if (runner.worker.name !== task.worker || runner.project !== task.project) {\n    return false\n  }\n  // by default, check that the environments are the same\n  // some workers (like vmThreads/vmForks) do not need this check\n  if (!runner.worker.canReuse) {\n    return isEnvironmentEqual(task.context.environment, runner.environment)\n  }\n  return runner.worker.canReuse(task)\n}\n\nfunction isEnvironmentEqual(env1: ContextTestEnvironment, env2: ContextTestEnvironment): boolean {\n  if (env1.name !== env2.name) {\n    return false\n  }\n  return deepEqual(env1.options, env2.options)\n}","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/node/pools/pool.ts#L299-L335","documentation":"Internal assertion in isEqualRunner (helper for Pool.getPoolRunner / shared runner reuse): the function is only ever called on the isolate:false reuse path, so receiving a task with task.isolate === true means the caller violated that contract. Isolated tasks must always get a fresh runner, never a reused shared one, so sharing one is rejected as a framework bug.","triggerScenarios":"isEqualRunner(runner, task) is called with task.isolate === true at packages/vitest/src/node/pools/pool.ts:315-317. The sharedRunners reuse path is gated on task.isolate === false upstream, so reaching the throw means that guard was bypassed.","commonSituations":"A regression in the isolate handling or sharedRunners logic; a custom worker whose canReuse/isolate contract is inconsistent; race during task reconfiguration.","solutions":["Report as a Vitest bug with reproduction (isolate config + the failing specs).","Avoid isolate:false if not needed to bypass the shared-runner path entirely.","Check that no custom PoolWorker/PoolRunner logic mutates task.isolate between scheduling and reuse."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await vitest.start()\n} catch (e) {\n  if (e.message === 'Isolated tasks should not share runners') {\n    console.error('Internal runner-reuse invariant violated — report as a Vitest bug.')\n  }\n  throw e\n}","preventionTips":["Pin stable Vitest versions to avoid runner-reuse regressions.","Avoid custom PoolWorker implementations that mutate task.isolate.","Report with reproduction including isolate config and the failing specs."],"tags":["pool","internal-bug","isolation","runner-reuse","assertion"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}