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

fix(visual-editor): handle circular pattern dependencies in the tree [SPA-2511] #946

Merged
merged 2 commits into from
Jan 23, 2025

Conversation

Chaoste
Copy link
Contributor

@Chaoste Chaoste commented Jan 22, 2025

Purpose

When accidentally causing a loop in the chain of pattern dependencies, the SDK would crash and the browser tab becomes not responsible.

Approach

To address this, we want to render a similar error as we do for missing component definitions. To detect a loop during the render cycle, we pass through a list of wrappingPatternIds that gets extended when "diving into" a pattern node.

To detect the loop as early as possible (and not pollute the canvas with multiple instances of a single pattern), we have to know the ID of the opened experience ID. When finding the same ID again deeper inside the tree, we stop immediately the rendering cycle and render the error message. To know the global experience ID, we leverage the blockId of the root node. So far, it was the same as the root node id. Using this for the entry ID sounds more reasonable to me and saves us from adding another attribute or message to the communication layer.

Note: This handles only the editor case. For preview/ delivery, there will be a separate PR

Screenshot 2025-01-22 at 17 29 17

@Chaoste Chaoste requested review from a team as code owners January 22, 2025 16:54
Copy link

vercel bot commented Jan 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nextjs-marketing-demo-bug-test ✅ Ready (Inspect) Visit Preview Jan 22, 2025 5:19pm
3 Skipped Deployments
Name Status Preview Updated (UTC)
experience-builder-test-app ⬜️ Ignored (Inspect) Jan 22, 2025 5:19pm
studio-nextjs-marketing-demo ⬜️ Ignored (Inspect) Jan 22, 2025 5:19pm
studio-react-vite-template ⬜️ Ignored (Inspect) Jan 22, 2025 5:19pm

Copy link
Contributor

@ChidinmaOrajiaku ChidinmaOrajiaku left a comment

Choose a reason for hiding this comment

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

Looks good and works well 👍

@Chaoste Chaoste merged commit eb6dcac into development Jan 23, 2025
17 checks passed
@Chaoste Chaoste deleted the fix/SPA-2511-circular-dep branch January 23, 2025 12:37
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