File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
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,8 +14,10 @@ export async function createRunnerFiles(
1314 pluginSlug : string ,
1415 configJSON : string ,
1516) : Promise < RunnerFilesPaths > {
16- const timestamp = Date . now ( ) . toString ( ) ;
17- const runnerWorkDir = path . join ( pluginWorkDir ( pluginSlug ) , timestamp ) ;
17+ // Use timestamp + process ID + threadId
18+ // This prevents race conditions when running the same plugin for multiple projects in parallel
19+ const uniqueId = `${ ( performance . timeOrigin + performance . now ( ) ) * 10 } -${ process . pid } -${ threadId } ` ;
20+ const runnerWorkDir = path . join ( pluginWorkDir ( pluginSlug ) , uniqueId ) ;
1821 const runnerConfigPath = path . join ( runnerWorkDir , 'plugin-config.json' ) ;
1922 const runnerOutputPath = path . join ( runnerWorkDir , 'runner-output.json' ) ;
2023
You can’t perform that action at this time.
0 commit comments