Skip to content

fix: simplify @log decorator and defer debug serialization#172

Merged
scolladon merged 1 commit intomainfrom
fix/simplify-log-decorator-to-trace-only
Feb 17, 2026
Merged

fix: simplify @log decorator and defer debug serialization#172
scolladon merged 1 commit intomainfrom
fix/simplify-log-decorator-to-trace-only

Conversation

@scolladon
Copy link
Copy Markdown
Owner

@scolladon scolladon commented Feb 17, 2026

Explain your changes

The @log decorator eagerly serialized method arguments and results via JSON.stringify on every invocation (9 usages across 9 files). For large XML merge operations, hot-path methods like XmlMerger.mergeThreeWay and MergeDriver.mergeFiles generated log entries with potentially MB-sized payloads (full XML trees). This could overwhelm pino's thread-stream transport, causing its hardcoded 10s flushSync timeout to fail at process exit.

Changes:

  • Simplify the @log decorator to only emit lightweight Logger.trace for entry/exit (class name + method name, no serialization)
  • Remove dead code (stringify, hasCustomToString, replacer) that was only used by the removed debug calls
  • Defer JSON.stringify in run.ts debug calls using lazy evaluation so serialization only happens when debug logging is enabled
  • Add missing valueSettings test case to reach 100% code coverage

Does this close any currently open issues?


  • Jest tests added to cover the fix.
  • NUT tests added to cover the fix.
  • E2E tests added to cover the fix.

Any particular element that can be tested locally

Run sf git merge driver run with debug logging enabled — the command should complete without _flushSync took too long errors on large XML files.

Any other comments

The root cause is that pino's thread-stream has a hardcoded 10s flush timeout (Atomics.wait with 10 spins × 1s) that is not configurable through @salesforce/core. Rather than trying to work around the timeout, this fix eliminates the log volume that causes it.

Trace-level entry/exit logging is preserved for execution flow debugging.

Remove eager JSON.stringify serialization from the @log decorator
(stringify, hasCustomToString, replacer) that ran on every invocation.
The decorator now only emits lightweight Logger.trace for entry/exit.

Also defer JSON.stringify in run.ts debug calls using lazy evaluation,
and add missing valueSettings test for 100% coverage.

Port of scolladon/sfdx-git-delta#1215.
@scolladon scolladon requested a review from yohanim as a code owner February 17, 2026 17:05
@github-actions
Copy link
Copy Markdown

Published under dev-172 npm channel.

$ sf plugins install sf-git-merge-driver@dev-172

Copy link
Copy Markdown
Collaborator

@yohanim yohanim left a comment

Choose a reason for hiding this comment

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

Waow, that's some great heavy logging optimization.
Eager to compare run times impact in real life.

@scolladon scolladon merged commit 07a8ce2 into main Feb 17, 2026
14 of 15 checks passed
@scolladon scolladon deleted the fix/simplify-log-decorator-to-trace-only branch February 17, 2026 17:32
@github-actions
Copy link
Copy Markdown

Shipped in release v1.5.3.
Version v1.5.3 will be assigned to the latest npm channel soon
Install it using either v1.5.3 or the latest-rc npm channel

$ sf plugins install sf-git-merge-driver@latest-rc
# Or
$ sf plugins install sf-git-merge-driver@v1.5.3

💡 Enjoying sf-git-merge-driver?
Your contribution helps us provide fast support 🚀 and high quality features 🔥
Become a sponsor 💙
Happy conflict merge free!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants