-
Notifications
You must be signed in to change notification settings - Fork 15
fix(js-client)!: enrich circular link dependencies #301
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes circular link dependency handling in the JavaScript client by replacing manual flag-based cycle prevention with a WeakSet-based tracking system. This ensures all linked objects are enriched while properly handling circular references.
- Replaced
_stopResolvingflag mechanism with aWeakSetto track enriched objects - Removed manual object copying (
_cleanCopy) to allow proper circular reference handling - Updated tree traversal to use WeakSet for cycle detection instead of path tracking
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Instead of manually setting a flag to stop enriching, we now check if an object has already been enriched. This ensures that all linked objects are enriched, even in cases of circular dependencies. A `WeakSet` is used to track enriched objects, ensuring they can be garbage collected when no longer referenced. BREAKING CHANGE: The client's output is no longer guaranteed to be serializable (e.g., with `JSON.stringify`). Due to the full resolution of circular dependencies, the resulting object graph may contain cycles. Fixes WDX-146
7399762 to
3b02402
Compare
@storyblok/astro
storyblok
@storyblok/eslint-config
@storyblok/js
storyblok-js-client
@storyblok/management-api-client
@storyblok/nuxt
@storyblok/react
@storyblok/region-helper
@storyblok/richtext
@storyblok/svelte
@storyblok/vue
commit: |
|
I do like the solution but given that it is a breaking change it might be worth holding off until we're comfortable bumping all the dependants too |
|
Switched to draft mode because we have to further investigate if this is a change we want to do. Postponing the decision to the new content API client. |
Instead of manually setting a flag to stop enriching, we now check if an object has already been enriched. This ensures that all linked objects are enriched, even in cases of circular dependencies.
A
WeakSetis used to track enriched objects, ensuring they can be garbage collected when no longer referenced.BREAKING CHANGE: The client's output is no longer guaranteed to be serializable (e.g., with
JSON.stringify). Due to the full resolution of circular dependencies, the resulting object graph may contain cycles.Fixes WDX-146