Skip to content

feat(utils): add WriteAheadLog classes - #1210

Merged
BioPhoton merged 48 commits into
mainfrom
feat/utils/file-sink
Jan 26, 2026
Merged

feat(utils): add WriteAheadLog classes#1210
BioPhoton merged 48 commits into
mainfrom
feat/utils/file-sink

Conversation

@BioPhoton

@BioPhotonBioPhoton commented Jan 9, 2026

Copy link
Copy Markdown
Collaborator

Related: #1197

This PR includes:

  • types for source sink flows
  • wal.ts - general WriteAheadLog and sharded WAL inc format and filenames
  • wal-trace-json.ts traceEvent specific login for a WAL
  • profiler constants to control WAL leader
  • moved trace utils into profiler

Note

This PR addresses a comment related to logging.
It could also be used as file output for the logger

Warning

All filesystem operations in WAL—and indirectly in the profiler—are synchronous by design.
The eslint rules are disables over file name pattern

Why synchronous fs is used for WAL code?

  • Profilers are side-channels, not business logic
  • Data must never be lost, reordered, or partially written
  • process.on('exit')cannot safely run async I/O
  • Sync writes guarantee ordering + durability
  • Profiler I/O volume is small → overhead is negligible
  • Crash-safety > throughput

Note

Introduces a synchronous Write-Ahead Log system and integrates it with profiler trace generation.

  • New wal.ts: WriteAheadLogFile, ShardedWal, codecs (stringCodec, createTolerantCodec), sharding IDs/paths, finalize/cleanup helpers, and AppendableSink interface
  • Profiler: add getProfilerId, new constants, and move/expand trace utils (trace-file-utils.ts) with encode/decode helpers, metadata, and entryToTraceEvents
  • New wal-json-trace.ts: generate complete Chrome trace content and expose traceEventWalFormat
  • Refactor PerformanceObserverSink to use AppendableSink.append and update mocks/tests; remove legacy sink-source.type.ts
  • Set realistic time origin in tests; add many unit/integration tests
  • ESLint: disable n/no-sync for wal*.ts files

Written by Cursor Bugbot for commit 953a3e7. This will update automatically on new commits. Configure here.

@nx-cloud

nx-cloudBot commented Jan 9, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 953a3e7

CommandStatusDurationResult
nx affected -t int-test --parallel=3✅ Succeeded1m 32sView ↗
nx affected -t unit-test --parallel=3✅ Succeeded43sView ↗

☁️ Nx Cloud last updated this comment at 2026-01-26 22:21:37 UTC

@pkg-pr-new

pkg-pr-newBot commented Jan 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@code-pushup/ci

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

@code-pushup/cli

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

@code-pushup/core

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

@code-pushup/create-cli

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

@code-pushup/models

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

@code-pushup/nx-plugin

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

@code-pushup/axe-plugin

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

@code-pushup/coverage-plugin

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

@code-pushup/eslint-plugin

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

@code-pushup/js-packages-plugin

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

@code-pushup/jsdocs-plugin

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

@code-pushup/lighthouse-plugin

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

@code-pushup/typescript-plugin

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

@code-pushup/utils

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

commit: 953a3e7

@github-actions

github-actionsBot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

Code PushUp

🤨 Code PushUp report has both improvements and regressions – compared current commit 276ae6b with previous commit ea27cdc.

🕵️ See full comparison in Code PushUp portal 🔍

🏷️ Categories

🏷️ Category⭐ Previous score⭐ Current score🔄 Score change
Performance🔴 29🔴 33↑ +4.6
Documentation🔴 42🔴 46↑ +3.6
Code coverage🟢 92🟢 93↑ +0.2
Bug prevention🟡 75🟡 75↓ −0.1
Axe Accessibility🟡 88🟡 88↓ −0.1
Code style🟢 100🟢 100
Security🔴 47🔴 47
Updates🟡 78🟡 78
Type Safety🟡 67🟡 67
Miscellaneous🟡 67🟡 67
Accessibility🟢 92🟢 92
Best Practices🟢 100🟢 100
SEO🟢 92🟢 92
👍 3 groups improved, 👍 13 audits improved, 12 audits changed without impacting score

🗃️ Groups

🔌 Plugin🗃️ Group⭐ Previous score⭐ Current score🔄 Score change
LighthousePerformance🔴 29🔴 33↑ +4.6
JSDocs coverageDocumentation coverage🔴 42🔴 46↑ +3.6
Code coverageCode coverage metrics🟢 92🟢 93↑ +0.2

31 other groups are unchanged.

🛡️ Audits

🔌 Plugin🛡️ Audit📏 Previous value📏 Current value🔄 Value change
LighthouseFirst Contentful Paint🟥 3.9 s🟥 3.2 s↓ −18.8 %
LighthouseSpeed Index🟥 9.3 s🟥 7.6 s↓ −18.2 %
JSDocs coverageClasses coverage🟥 6 undocumented classes🟨 6 undocumented classes +0 %
JSDocs coverageProperties coverage🟥 30 undocumented properties🟥 41 undocumented properties↑ +36.7 %
LighthouseTime to Interactive🟥 17.7 s🟥 13.7 s↓ −22.6 %
LighthouseTotal Blocking Time🟥 7,300 ms🟥 2,310 ms↓ −68.4 %
JSDocs coverageFunctions coverage🟥 579 undocumented functions🟥 582 undocumented functions↑ +0.5 %
JSDocs coverageTypes coverage🟥 272 undocumented types🟥 262 undocumented types↓ −3.7 %
JSDocs coverageMethods coverage🟨 13 undocumented methods🟨 15 undocumented methods↑ +15.4 %
JSDocs coverageVariables coverage🟥 272 undocumented variables🟥 280 undocumented variables↑ +2.9 %
Code coverageBranch coverage🟨 89 %🟨 89.2 %↑ +0.3 %
Code coverageLine coverage🟩 92.3 %🟩 92.6 %↑ +0.2 %
Code coverageFunction coverage🟩 94.1 %🟩 94.3 %↑ +0.2 %
LighthouseMinimizes main-thread work🟥 24.2 s🟥 11.9 s↓ −50.7 %
LighthouseAvoids enormous network payloads🟩 Total size was 2,098 KiB🟩 Total size was 2,087 KiB↓ −0.5 %
LighthouseJavaScript execution time🟥 9.6 s🟥 4.9 s↓ −48.5 %
LighthouseMetrics🟩 100%🟩 100%↓ −22.6 %
LighthouseLargest Contentful Paint🟥 14.5 s🟥 11.5 s↓ −20.4 %
LighthouseMax Potential First Input Delay🟥 3,650 ms🟥 1,250 ms↓ −65.9 %
LighthouseServer Backend Latencies🟩 1,040 ms🟩 300 ms↓ −70.8 %
LighthouseUses efficient cache policy on static assets🟨 31 resources found🟨 31 resources found↓ −0.1 %
LighthouseReduce unused CSS🟥 Potential savings of 125 KiB🟥 Potential savings of 125 KiB↑ +7.1 %
LighthouseInitial server response time was short🟩 Root document took 560 ms🟩 Root document took 580 ms↑ +4.9 %
LighthouseReduce unused JavaScript🟥 Potential savings of 226 KiB🟥 Potential savings of 226 KiB↓ −0.9 %
LighthouseNetwork Round Trip Times🟩 20 ms🟩 20 ms↑ +28.5 %

654 other audits are unchanged.

@github-actions

github-actionsBot commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

Code PushUp

🥳 Code PushUp report has improved – compared current commit 276ae6b with previous commit ea27cdc.

💼 Project utils

🥳 Code PushUp report has improved.

🕵️ See full comparison in Code PushUp portal 🔍

🏷️ Category⭐ Previous score⭐ Current score🔄 Score change
Documentation🔴 46🟡 51↑ +5.6
Code coverage🟢 95🟢 95↑ +0.3

4 other categories are unchanged.

👍 2 groups improved, 👍 9 audits improved

🗃️ Groups

🔌 Plugin🗃️ Group⭐ Previous score⭐ Current score🔄 Score change
JSDocs coverageDocumentation coverage🔴 46🟡 51↑ +5.6
Code coverageCode coverage metrics🟢 95🟢 95↑ +0.3

13 other groups are unchanged.

🛡️ Audits

🔌 Plugin🛡️ Audit📏 Previous value📏 Current value🔄 Value change
JSDocs coverageClasses coverage🟨 3 undocumented classes🟨 3 undocumented classes +0 %
JSDocs coverageProperties coverage🟥 27 undocumented properties🟥 38 undocumented properties↑ +40.7 %
JSDocs coverageTypes coverage🟥 66 undocumented types🟨 56 undocumented types↓ −15.2 %
JSDocs coverageFunctions coverage🟥 241 undocumented functions🟥 244 undocumented functions↑ +1.2 %
JSDocs coverageMethods coverage🟨 13 undocumented methods🟨 15 undocumented methods↑ +15.4 %
JSDocs coverageVariables coverage🟥 49 undocumented variables🟥 57 undocumented variables↑ +16.3 %
Code coverageBranch coverage🟩 91.7 %🟩 92.2 %↑ +0.5 %
Code coverageFunction coverage🟩 95.7 %🟩 96 %↑ +0.3 %
Code coverageLine coverage🟩 97.7 %🟩 97.9 %↑ +0.1 %

435 other audits are unchanged.


13 other projects are unchanged.

@BioPhotonBioPhoton changed the title feat(utils): add file sink classesfeat(utils): add WriteAheadLog classesJan 18, 2026

@hanna-skrylhanna-skryl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The justification for sync file operations is well-reasoned 👍 I've added a few minor suggestions and comments.

Comment threadpackages/utils/src/lib/wal.ts Outdated
Comment threadpackages/utils/src/lib/wal.ts Outdated
Comment threadpackages/utils/mocks/sink.mock.ts Outdated
Comment threadpackages/utils/src/lib/profiler/wal-json-trace.unit.test.ts Outdated
Comment threadpackages/utils/src/lib/wal.ts Outdated
Comment threadpackages/utils/src/lib/wal.ts
Comment threadpackages/utils/src/lib/wal.ts Outdated
Comment threadpackages/utils/src/lib/wal.ts Outdated
Comment threadpackages/utils/src/lib/wal.ts Outdated
Comment threadpackages/utils/src/lib/wal.ts Outdated
BioPhotonand others added 3 commits January 19, 2026 21:48
Co-authored-by: Hanna Skryl <80118140+hanna-skryl@users.noreply.github.com>
Co-authored-by: Hanna Skryl <80118140+hanna-skryl@users.noreply.github.com>
Co-authored-by: Hanna Skryl <80118140+hanna-skryl@users.noreply.github.com>
Comment threadpackages/utils/src/lib/profiler/wal-json-trace.unit.test.ts Outdated
Comment threadpackages/utils/src/lib/profiler/wal-json-trace.ts Outdated
# Conflicts:
#	packages/utils/src/lib/performance-observer.int.test.ts
#	packages/utils/src/lib/profiler/profiler.unit.test.ts
Comment threadpackages/utils/src/lib/wal.ts
Comment threadpackages/utils/src/lib/profiler/wal-json-trace.ts Outdated
Comment threadpackages/utils/src/lib/wal.ts Outdated

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is ON, but it could not run because Privacy Mode (Legacy) is turned on. To enable Bugbot Autofix, switch your privacy mode in the Cursor dashboard.

Comment threadpackages/utils/src/lib/profiler/wal-json-trace.ts
Comment threadpackages/utils/eslint.config.js
Comment threadpackages/utils/src/lib/sink-source.type.ts
Comment threadpackages/utils/src/lib/wal.ts
@BioPhoton
BioPhoton merged commit e677d4f into mainJan 26, 2026
36 of 38 checks passed
@BioPhoton
BioPhoton deleted the feat/utils/file-sink branch January 26, 2026 23:41
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@BioPhoton@matejchalk@hanna-skryl