Skip to content

Commit 49d8341

Browse files
committed
chore: adress feedbacks
1 parent 4e24f73 commit 49d8341

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/utils/src/lib/create-runner-files.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { writeFile } from 'node:fs/promises';
22
import path from 'node:path';
3+
import { threadId } from 'node:worker_threads';
34
import type { RunnerFilesPaths } from '@code-pushup/models';
45
import { ensureDirectoryExists, pluginWorkDir } from './file-system.js';
56

@@ -13,10 +14,9 @@ export async function createRunnerFiles(
1314
pluginSlug: string,
1415
configJSON: string,
1516
): Promise<RunnerFilesPaths> {
16-
// Use timestamp + process ID + random suffix to ensure uniqueness
17+
// Use timestamp + process ID + threadId
1718
// This prevents race conditions when running the same plugin for multiple projects in parallel
18-
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
19-
const uniqueId = `${Date.now()}-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
19+
const uniqueId = `${(performance.timeOrigin + performance.now()) * 10}-${process.pid}-${threadId}`;
2020
const runnerWorkDir = path.join(pluginWorkDir(pluginSlug), uniqueId);
2121
const runnerConfigPath = path.join(runnerWorkDir, 'plugin-config.json');
2222
const runnerOutputPath = path.join(runnerWorkDir, 'runner-output.json');

0 commit comments

Comments
 (0)