Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Improve calculateChangeHash to avoid circular reference errors #403

Conversation

sw-joelmut
Copy link

#minor

Description

This PR updates the internal BotState cache hash functionality to prevent JSON.stringify from throwing circular reference errors, and generates from the resulted string a hash using the node:crypto library.

Specific Changes

  • Updates the calculateChangeHash with an improved functionality.
  • Prevent the JSON.stringify from throwing circular reference errors.
  • Detect circular objects and replace the reference with a string value pointing out to the located path, helpful for future debugging and tracing.
  • Added the node:crypto library to generate a hash value that is easier to use for debugging and storing.

Testing

The following images show how this new functionality detects and replaces circular references, and the generated hash string.
image
image

@sw-joelmut sw-joelmut changed the title Improve calculateChangeHash to avoid circular reference errors refactor: Improve calculateChangeHash to avoid circular reference errors Jan 25, 2024
@sw-joelmut
Copy link
Author

image

@sw-joelmut sw-joelmut closed this Feb 28, 2024
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.

3 participants