Skip to content

Conversation

@BioPhoton
Copy link
Collaborator

@BioPhoton BioPhoton commented Jan 16, 2026

Related: #1197

This PR includes:

  • adding NodeJSProfiler class
  • implemented performanceObserver for NodeJSProfiler
  • revamp PerformanceObserverSink - add getStatus for better testing, more robust and memory friendly buffer logic

- Add explanation that sink determines output format (DevTools TraceEvent, OpenTelemetry, etc.)
- Improve documentation clarity for flexible serialization capabilities
- Fix duplicate imports in profiler unit test
- Replace method implementations with vi.fn() spy functions
- Add vi import from vitest
- Enables better testing with call tracking and assertions
@github-actions github-actions bot added 📖 Project documentation improvements or additions to the project documentation 🔬 testing writing tests 🧩 utils labels Jan 16, 2026
@nx-cloud
Copy link

nx-cloud bot commented Jan 16, 2026

View your CI Pipeline Execution ↗ for commit 9b75840

Command Status Duration Result
nx run ci:code-pushup -- merge-diffs --files=/h... ✅ Succeeded 5s View ↗
nx run-many --targets=code-pushup --parallel=fa... ✅ Succeeded 1m 30s View ↗
nx run-many --targets=code-pushup --parallel=fa... ✅ Succeeded 12m 55s View ↗
nx run-many -t unit-test,int-test ✅ Succeeded 53s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-19 14:42:44 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 16, 2026

Open in StackBlitz

@code-pushup/ci

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

@code-pushup/cli

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

@code-pushup/core

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

@code-pushup/create-cli

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

@code-pushup/models

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

@code-pushup/nx-plugin

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

@code-pushup/axe-plugin

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

@code-pushup/coverage-plugin

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

@code-pushup/eslint-plugin

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

@code-pushup/js-packages-plugin

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

@code-pushup/jsdocs-plugin

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

@code-pushup/lighthouse-plugin

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

@code-pushup/typescript-plugin

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

@code-pushup/utils

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

commit: 9b75840

@github-actions
Copy link
Contributor

github-actions bot commented Jan 16, 2026

Code PushUp

🤨 Code PushUp report has both improvements and regressions – compared current commit b341e30 with previous commit 270b474.

🕵️ See full comparison in Code PushUp portal 🔍

🏷️ Categories

🏷️ Category ⭐ Previous score ⭐ Current score 🔄 Score change
Documentation 🔴 42 🟡 50 ↑ +8.3
Performance 🔴 37 🔴 32 ↓ −5
Code style 🟢 99 🟢 100 ↑ +0.4
Code coverage 🟢 93 🟢 92 ↓ −0.1
Bug prevention 🟡 75 🟡 75 ↓ −0.1
Axe Accessibility 🟡 88 🟡 88 ↓ −0.1
Security 🟡 51 🟡 51
Updates 🟡 78 🟡 78
Type Safety 🟡 67 🟡 67
Miscellaneous 🟡 67 🟡 67
Accessibility 🟢 92 🟢 92
Best Practices 🟢 100 🟢 100
SEO 🟢 92 🟢 92
👍 3 groups improved, 👎 2 groups regressed, 👍 7 audits improved, 👎 8 audits regressed, 20 audits changed without impacting score

🗃️ Groups

🔌 Plugin 🗃️ Group ⭐ Previous score ⭐ Current score 🔄 Score change
ESLint Style guide (import) 🟡 80 🟢 100 ↑ +20
JSDocs coverage Documentation coverage 🔴 42 🟡 50 ↑ +8.3
Lighthouse Performance 🔴 37 🔴 32 ↓ −5
ESLint Suggestions 🟢 99 🟢 100 ↑ +0.4
Code coverage Code coverage metrics 🟢 93 🟢 92 ↓ −0.1

29 other groups are unchanged.

🛡️ Audits

🔌 Plugin 🛡️ Audit 📏 Previous value 📏 Current value 🔄 Value change
Lighthouse Initial server response time was short 🟩 Root document took 540 ms 🟥 Root document took 620 ms ↑ +15.9 %
ESLint Forbid unassigned imports 🟥 1 warning 🟩 passed ↓ −100 %
JSDocs coverage Properties coverage 🟥 30 undocumented properties 🟥 26 undocumented properties ↓ −13.3 %
Lighthouse Speed Index 🟥 6.0 s 🟥 7.9 s ↑ +30.4 %
JSDocs coverage Methods coverage 🟨 13 undocumented methods 🟨 9 undocumented methods ↓ −30.8 %
JSDocs coverage Classes coverage 🟥 6 undocumented classes 🟨 5 undocumented classes ↓ −16.7 %
Lighthouse Total Blocking Time 🟥 1,890 ms 🟥 3,070 ms ↑ +62.7 %
Lighthouse First Contentful Paint 🟥 3.1 s 🟥 3.3 s ↑ +6.7 %
Lighthouse Time to Interactive 🟥 13.0 s 🟥 13.8 s ↑ +5.8 %
JSDocs coverage Variables coverage 🟥 268 undocumented variables 🟥 267 undocumented variables ↓ −0.4 %
JSDocs coverage Types coverage 🟥 268 undocumented types 🟥 267 undocumented types ↓ −0.4 %
Code coverage Line coverage 🟩 92.7 % 🟩 92.4 % ↓ −0.3 %
JSDocs coverage Functions coverage 🟥 577 undocumented functions 🟥 577 undocumented functions  +0 %
Code coverage Function coverage 🟩 94.4 % 🟩 94.2 % ↓ −0.1 %
Code coverage Branch coverage 🟨 89 % 🟨 88.9 % ↓ −0.1 %
Lighthouse Avoids enormous network payloads 🟩 Total size was 2,104 KiB 🟩 Total size was 2,111 KiB ↑ +0.3 %
Lighthouse Minimizes main-thread work 🟥 9.2 s 🟥 12.4 s ↑ +34.5 %
Lighthouse Uses efficient cache policy on static assets 🟨 31 resources found 🟨 31 resources found ↑ +0.4 %
Lighthouse JavaScript execution time 🟥 4.3 s 🟥 5.6 s ↑ +31 %
Lighthouse Largest Contentful Paint 🟥 11.5 s 🟥 12.3 s ↑ +7.1 %
Lighthouse Metrics 🟩 100% 🟩 100% ↑ +5.8 %
Lighthouse Max Potential First Input Delay 🟥 980 ms 🟥 1,690 ms ↑ +72 %
Lighthouse Server Backend Latencies 🟩 1,200 ms 🟩 740 ms ↓ −38.8 %
Lighthouse Reduce unused JavaScript 🟥 Potential savings of 224 KiB 🟥 Potential savings of 225 KiB ↓ −22.6 %
Lighthouse Network Round Trip Times 🟩 10 ms 🟩 70 ms ↑ +903.3 %
Lighthouse Remove duplicate modules in JavaScript bundles 🟥 Potential savings of 93 KiB 🟥 Potential savings of 93 KiB ↓ −2.2 %
Lighthouse Avoids an excessive DOM size 🟥 2,403 elements 🟥 2,405 elements ↑ +0.1 %
Axe Elements must only use supported ARIA attributes 🟩 100 elements 🟩 102 elements ↑ +2 %
Axe ARIA attributes must be used as specified for the element's role 🟩 100 elements 🟩 102 elements ↑ +2 %
Axe Elements must only use permitted ARIA attributes 🟩 100 elements 🟩 102 elements ↑ +2 %
Axe ARIA attributes must conform to valid names 🟩 100 elements 🟩 102 elements ↑ +2 %
JS packages Outdated npm prod dependencies. 🟨 16 outdated package versions (5 major, 8 minor, 3 patch) 🟨 15 outdated package versions (5 major, 8 minor, 2 patch) ↓ −6.2 %
JS packages Outdated npm dev dependencies. 🟨 56 outdated package versions (29 major, 19 minor, 8 patch) 🟨 55 outdated package versions (29 major, 19 minor, 7 patch) ↓ −1.8 %
Axe Inline text spacing must be adjustable with custom stylesheets 🟩 43 elements 🟩 42 elements ↓ −2.3 %
Axe Interactive controls must not be nested 🟩 61 elements 🟩 60 elements ↓ −1.6 %

644 other audits are unchanged.

@BioPhoton BioPhoton marked this pull request as ready for review January 16, 2026 22:22
@github-actions
Copy link
Contributor

github-actions bot commented Jan 16, 2026

Code PushUp

🤨 Code PushUp report has both improvements and regressions – compared current commit b341e30 with previous commit 270b474.

💼 Project utils

🤨 Code PushUp report has both improvements and regressions.

🕵️ See full comparison in Code PushUp portal 🔍

🏷️ Category ⭐ Previous score ⭐ Current score 🔄 Score change
Documentation 🔴 45 🟡 56 ↑ +10.8
Code coverage 🟢 95 🟢 95 ↓ −0.2

4 other categories are unchanged.

👍 1 group improved, 👎 1 group regressed, 👍 6 audits improved, 👎 3 audits regressed

🗃️ Groups

🔌 Plugin 🗃️ Group ⭐ Previous score ⭐ Current score 🔄 Score change
JSDocs coverage Documentation coverage 🔴 45 🟡 56 ↑ +10.8
Code coverage Code coverage metrics 🟢 95 🟢 95 ↓ −0.2

13 other groups are unchanged.

🛡️ Audits

🔌 Plugin 🛡️ Audit 📏 Previous value 📏 Current value 🔄 Value change
JSDocs coverage Properties coverage 🟥 27 undocumented properties 🟥 23 undocumented properties ↓ −14.8 %
JSDocs coverage Classes coverage 🟨 3 undocumented classes 🟨 2 undocumented classes ↓ −33.3 %
JSDocs coverage Methods coverage 🟨 13 undocumented methods 🟨 9 undocumented methods ↓ −30.8 %
JSDocs coverage Variables coverage 🟥 49 undocumented variables 🟥 48 undocumented variables ↓ −2 %
JSDocs coverage Types coverage 🟥 66 undocumented types 🟥 65 undocumented types ↓ −1.5 %
JSDocs coverage Functions coverage 🟥 239 undocumented functions 🟥 239 undocumented functions  +0 %
Code coverage Branch coverage 🟩 91.8 % 🟩 91.6 % ↓ −0.3 %
Code coverage Function coverage 🟩 96.2 % 🟩 96 % ↓ −0.2 %
Code coverage Line coverage 🟩 97.8 % 🟩 97.8 % ↓ −0.1 %

435 other audits are unchanged.


13 other projects are unchanged.

Co-authored-by: Hanna Skryl <80118140+hanna-skryl@users.noreply.github.com>
@BioPhoton BioPhoton requested a review from hanna-skryl January 18, 2026 17:41
Comment on lines +212 to 215
* @throws {Error} If the sink is closed before subscription
*
*/
subscribe(): void {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The subscribe() method doesn't actually check if the sink is closed or throw an error. 🤔

Comment on lines +244 to +247
/** Sink for buffering and flushing performance data
* @NOTE this is dummy code and will be replaced by PR #1210
**/
sink: Sink<DomainEvents, unknown> & Recoverable;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the intention here to wait until the referenced PR merges and refactor this fragment?

Comment on lines +467 to +469
it('should write to file on flush', () => {
expect(true).toBe(true);
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

What are you checking here? 😅


// Initial state: idle
expect(profiler.isRunning()).toBe(false);
expect(profiler.activeat()).toBe(false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
expect(profiler.activeat()).toBe(false);
expect(profiler.activate()).toBe(false);

Comment on lines +271 to +277
try {
this.#queue.forEach(item => {
this.#sink.write(item);
this.#written++;
});
} catch (error) {
this.#dropped += this.#queue.length;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like #dropped can potentially overcount if write() throws partway through the queue.

}
this.#observer?.disconnect();
this.flush();
this.#queue.length = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

The this.#queue.length = 0 line is redundant since flush() always clears the queue in its finally block.

Suggested change
this.#queue.length = 0;

Comment on lines 102 to 108
* This means any future {@link Profiler} instantiations (including child processes) will use the same enabled state.
*
* @param enabled - Whether profiling should be enabled
*/
setEnabled(enabled: boolean): void {
process.env[PROFILER_ENABLED_ENV_VAR] = `${enabled}`;
this.#enabled = enabled;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

The JSDoc doesn't match the implementation now that setEnabled intentionally only modifies the instance's private state.

Comment on lines +640 to +641
expect(profiler.isEnabled()).toBe(false);
expect(sink.isClosed()).toBe(true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was about to suggest replacing toBe(true)/toBe(false) with toBeTrue()/toBeFalse() per our jest-extended rules, but then started wondering why ESLint wasn't flagging these automatically. After investigating, I found the root cause.

eslint-plugin-jest-extended only detects global expect, not imported expect. Since test files explicitly import from vitest, ESLint sees expect as an imported identifier, not a global, so the rules never match.

Vitest config factory already includes globals: true, so these imports are redundant at runtime. Removing them would enable jest-extended ESLint rules to fire correctly and surface existing violations.

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

Labels

📖 Project documentation improvements or additions to the project documentation 🔬 testing writing tests 🧩 utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants