Skip to content

Conversation

@mondoreale
Copy link
Contributor

@mondoreale mondoreale commented Dec 29, 2025

This pull request refactors and improves utility modules in the codebase, focusing on the Logger and SigningUtil classes, as well as minor optimizations in binary utilities and error handling. The main changes include a redesign of the logger initialization for better encapsulation, simplification of the signing utility instantiation logic, and minor performance and correctness tweaks.

Note

This is just the first step (alongside the recent utils refactoring). Other packages will follow to make the whole thing much more convenient to use.

Changes

Logger improvements:

  • Refactored the Logger class to encapsulate the root logger initialization in a static method, removing the global rootLogger variable and improving encapsulation. The logger now lazily initializes the root logger as needed. [1] [2] [3]
  • Improved the logger method wrapping logic to ensure consistent logging behavior in browser environments. [1] [2]

Signing utility simplification:

  • Simplified the SigningUtil.getInstance method by replacing the static keyTypeToInstance map with a switch statement that directly instantiates the correct class for each key type. This removes unnecessary static instances and clarifies the instantiation logic. [1] [2]

Utility optimizations:

  • Updated binaryUtils.ts to create new TextEncoder and TextDecoder instances on each call instead of using shared instances, preventing potential state issues and improving reliability.

Error handling improvements:

  • Moved the creation of the logger instance inside the executeSafePromise function to ensure a fresh logger is used for each invocation, and removed the unnecessary top-level logger instance.

Future steps

  • Propagate the same technique throughout the other packages.

@cursor
Copy link

cursor bot commented Dec 29, 2025

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on January 28.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@github-actions github-actions bot added the utils label Dec 29, 2025
…vitewebpack-app-requires-polyfilling' into utils-without-side-effects
Sign up for free to 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.

2 participants