Skip to content

Conversation

@beaussan
Copy link
Contributor

Summary

Fixes a race condition when running the same plugin for multiple projects in parallel (e.g., via Nx targets).

Problem

When two processes started within the same millisecond, the timestamp-based directory naming in createRunnerFiles would collide:

node_modules/.code-pushup/{pluginSlug}/{timestamp}/

This caused one process to delete the output directory (in executeRunnerConfig) while another was still using it, leading to failures.

Solution

Added process.pid and a random suffix to the directory name to ensure uniqueness:

const uniqueId = `${Date.now()}-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;

This ensures that even when multiple processes run simultaneously, each gets its own unique working directory.

When running the same plugin for multiple projects in parallel (e.g., via
Nx targets), the timestamp-based directory naming could collide if two
processes started within the same millisecond.

This caused one process to delete the output directory while another was
still using it, leading to failures.

The fix adds process.pid and a random suffix to the directory name,
ensuring uniqueness even when multiple processes run simultaneously.
@nx-cloud
Copy link

nx-cloud bot commented Jan 19, 2026

View your CI Pipeline Execution ↗ for commit 4e24f73

Command Status Duration Result
nx affected -t e2e-test --parallel=1 ✅ Succeeded 13m 37s View ↗
nx affected -t lint --parallel=3 ✅ Succeeded 2m 48s View ↗
nx affected -t int-test --parallel=3 ✅ Succeeded 1m 34s View ↗
nx affected -t unit-test --parallel=3 ✅ Succeeded 41s View ↗
nx run-many --target=build --parallel=3 ✅ Succeeded 34s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-19 21:34:05 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 19, 2026

Open in StackBlitz

@code-pushup/ci

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/ci@1222

@code-pushup/cli

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/cli@1222

@code-pushup/core

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/core@1222

@code-pushup/create-cli

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/create-cli@1222

@code-pushup/models

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/models@1222

@code-pushup/nx-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/nx-plugin@1222

@code-pushup/axe-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/axe-plugin@1222

@code-pushup/coverage-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/coverage-plugin@1222

@code-pushup/eslint-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/eslint-plugin@1222

@code-pushup/js-packages-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/js-packages-plugin@1222

@code-pushup/jsdocs-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/jsdocs-plugin@1222

@code-pushup/lighthouse-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/lighthouse-plugin@1222

@code-pushup/typescript-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/typescript-plugin@1222

@code-pushup/utils

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/utils@1222

commit: 4e24f73

@beaussan beaussan marked this pull request as ready for review January 19, 2026 21:18
@github-actions
Copy link
Contributor

github-actions bot commented Jan 19, 2026

Code PushUp

😟 Code PushUp report has regressed – compared current commit 1d7ffda with previous commit 1d7ffda.

🏷️ Categories

🏷️ Category ⭐ Previous score ⭐ Current score 🔄 Score change
Performance 🔴 41 🔴 34 ↓ −6.7
Bug prevention 🟡 75 🟡 75
Code style 🟢 100 🟢 100
Code coverage 🟢 92 🟢 92
Security 🟡 51 🟡 51
Updates 🟡 78 🟡 78
Type Safety 🟡 67 🟡 67
Miscellaneous 🟡 67 🟡 67
Documentation 🔴 42 🔴 42
Accessibility 🟢 92 🟢 92
Best Practices 🟢 100 🟢 100
SEO 🟢 92 🟢 92
Axe Accessibility 🟡 88 🟡 88
👎 1 group regressed, 👎 5 audits regressed, 11 audits changed without impacting score

🗃️ Groups

🔌 Plugin 🗃️ Group ⭐ Previous score ⭐ Current score 🔄 Score change
Lighthouse Performance 🔴 41 🔴 34 ↓ −6.7

33 other groups are unchanged.

🛡️ Audits

🔌 Plugin 🛡️ Audit 📏 Previous value 📏 Current value 🔄 Value change
Lighthouse Total Blocking Time 🟥 1,140 ms 🟥 2,370 ms ↑ +107.5 %
Lighthouse Speed Index 🟥 5.8 s 🟥 6.9 s ↑ +17.7 %
Lighthouse Max Potential First Input Delay 🟥 470 ms 🟥 1,370 ms ↑ +189.4 %
Lighthouse Time to Interactive 🟥 12.9 s 🟥 13.5 s ↑ +4.7 %
Lighthouse First Contentful Paint 🟥 3.1 s 🟥 3.1 s ↑ +0.9 %
Lighthouse Minimizes main-thread work 🟥 6.9 s 🟥 11.1 s ↑ +61.3 %
Lighthouse JavaScript execution time 🟥 3.1 s 🟥 5.2 s ↑ +69.7 %
Lighthouse Largest Contentful Paint 🟥 11.0 s 🟥 12.0 s ↑ +8.9 %
Lighthouse Metrics 🟩 100% 🟩 100% ↑ +4.7 %
Lighthouse Avoids enormous network payloads 🟩 Total size was 2,112 KiB 🟩 Total size was 2,112 KiB ↓ −0.1 %
Lighthouse Uses efficient cache policy on static assets 🟨 31 resources found 🟨 31 resources found ↑ +0.1 %
Lighthouse Reduce unused JavaScript 🟥 Potential savings of 226 KiB 🟥 Potential savings of 226 KiB ↓ −12.5 %
Lighthouse Remove duplicate modules in JavaScript bundles 🟥 Potential savings of 93 KiB 🟥 Potential savings of 93 KiB ↓ −33.3 %
Lighthouse Server Backend Latencies 🟩 810 ms 🟩 900 ms ↑ +10.2 %
Lighthouse Initial server response time was short 🟩 Root document took 480 ms 🟩 Root document took 540 ms ↑ +12.4 %
Lighthouse Network Round Trip Times 🟩 70 ms 🟩 70 ms ↓ −3.7 %

663 other audits are unchanged.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 19, 2026

Code PushUp

😐 Code PushUp report is unchanged – compared current commit 1d7ffda with previous commit 1d7ffda.


All of 14 projects are unchanged.

Copy link
Collaborator

@BioPhoton BioPhoton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a suggestion

// Use timestamp + process ID + random suffix to ensure uniqueness
// This prevents race conditions when running the same plugin for multiple projects in parallel
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
const uniqueId = `${Date.now()}-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
Copy link
Collaborator

@BioPhoton BioPhoton Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const uniqueId = `${Date.now()}-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
const uniqueId = `${(performance.timeOrigin+performance.now())*10}-${process.pid}-${threadId}`;
  • We can get an additional digit from perf_hooks which is also monotonic: (performance.timeOrigin+performance.now())*10
  • Processes can have multiple threads threadId is 0 by default

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why there is a random suffix. Imo, process + suffix is good enough, but I'll let the rest of the team confirm that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants