File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 11import { writeFile } from 'node:fs/promises' ;
22import path from 'node:path' ;
3+ import { threadId } from 'node:worker_threads' ;
34import type { RunnerFilesPaths } from '@code-pushup/models' ;
45import { 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' ) ;
You can’t perform that action at this time.
0 commit comments