File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,6 +73,9 @@ export class Pool {
7373 let isMemoryLimitReached = false
7474 const runner = this . getPoolRunner ( task , method )
7575
76+ const poolId = runner . poolId ?? this . getWorkerId ( )
77+ runner . poolId = poolId
78+
7679 const activeTask = { task, resolver, method, cancelTask }
7780 this . activeTasks . push ( activeTask )
7881
@@ -113,9 +116,6 @@ export class Pool {
113116 await runner . start ( ) . finally ( ( ) => clearTimeout ( id ) )
114117 }
115118
116- const poolId = runner . poolId ?? this . getWorkerId ( )
117- runner . poolId = poolId
118-
119119 const span = runner . startTracesSpan ( `vitest.worker.${ method } ` )
120120 // Start running the test in the worker
121121 runner . request ( method , task . context )
Original file line number Diff line number Diff line change @@ -127,7 +127,6 @@ export class PoolRunner {
127127 __vitest_worker_request__ : true ,
128128 type : method ,
129129 context,
130- poolId : this . poolId ! ,
131130 otelCarrier : this . getOTELCarrier ( ) ,
132131 } satisfies WorkerRequest )
133132 }
@@ -182,6 +181,7 @@ export class PoolRunner {
182181
183182 this . postMessage ( {
184183 type : 'start' ,
184+ poolId : this . poolId ! ,
185185 __vitest_worker_request__ : true ,
186186 options : {
187187 reportMemory : this . worker . reportMemory ?? false ,
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ export type WorkerRequest
7070 = { __vitest_worker_request__ : true } & (
7171 | {
7272 type : 'start'
73+ poolId : number
7374 options : { reportMemory : boolean }
7475 context : {
7576 environment : WorkerTestEnvironment
@@ -89,13 +90,11 @@ export type WorkerRequest
8990 | {
9091 type : 'run'
9192 context : WorkerExecuteContext
92- poolId : number
9393 otelCarrier ?: OTELCarrier
9494 }
9595 | {
9696 type : 'collect'
9797 context : WorkerExecuteContext
98- poolId : number
9998 otelCarrier ?: OTELCarrier
10099 }
101100 | { type : 'cancel' }
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ export function init(worker: Options): void {
4141
4242 switch ( message . type ) {
4343 case 'start' : {
44+ process . env . VITEST_POOL_ID = String ( message . poolId )
4445 reportMemory = message . options . reportMemory
4546
4647 const tracesStart = performance . now ( )
@@ -96,7 +97,6 @@ export function init(worker: Options): void {
9697 }
9798
9899 try {
99- process . env . VITEST_POOL_ID = String ( message . poolId )
100100 process . env . VITEST_WORKER_ID = String ( message . context . workerId )
101101 }
102102 catch ( error ) {
@@ -155,7 +155,6 @@ export function init(worker: Options): void {
155155 }
156156
157157 try {
158- process . env . VITEST_POOL_ID = String ( message . poolId )
159158 process . env . VITEST_WORKER_ID = String ( message . context . workerId )
160159 }
161160 catch ( error ) {
You can’t perform that action at this time.
0 commit comments