Skip to content

Commit fc5a231

Browse files
committed
test: spread deterministic port blocks by process
1 parent 1628217 commit fc5a231

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎src/test-utils/ports.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ export async function getDeterministicFreePortBlock(params?: {
4848

4949
const workerIdRaw = process.env.VITEST_WORKER_ID ?? process.env.VITEST_POOL_ID ?? "";
5050
const workerId = Number.parseInt(workerIdRaw, 10);
51+
const processShard = Math.abs(process.pid);
5152
const shard = Number.isFinite(workerId)
52-
? Math.max(0, workerId)
53+
? Math.max(0, workerId) + processShard
5354
: isMainThread
54-
? Math.abs(process.pid)
55-
: Math.abs(threadId);
55+
? processShard
56+
: processShard + Math.abs(threadId);
5657

5758
const rangeSize = 1000;
58-
const shardCount = 30;
59+
const shardCount = 35;
5960
const base = 30_000 + (Math.abs(shard) % shardCount) * rangeSize; // <= 59_999
6061
const usable = rangeSize - maxOffset;
6162

0 commit comments

Comments
 (0)