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

Pages with blocks but no blocks layout cause a browser process hangup (tab or browser crash) #6742

Open
JeffersonBledsoe opened this issue Feb 10, 2025 · 1 comment · May be fixed by #6753
Labels
01 type: bug 30 needs: triage New issue that needs confirmation before work begins

Comments

@JeffersonBledsoe
Copy link
Member

Describe the bug

If a page contains blocks but it's items key in the blocks_layout is empty, entering edit mode will cause a recursion error and cause the page to crash.
This is due to the check for invalid blocks within the BlocksForm component:

for (const [n, v] of blockList) {
if (!v) {
const newFormData = deleteBlock(properties, n, intl);
onChangeFormData(newFormData);
}
}
. onChangeFormData triggers a state update in the Form component:
onChangeFormData={(newData) => {
const newFormData = {
...formData,
...newData,
};
this.setState({
formData: newFormData,
});
if (this.props.global) {
this.props.setFormData(newFormData);
}
}}

This state update during render is already a bad pattern as it causes unwanted side effects, but in this case it will re-render the Form component while the BlocksForm is still trying to render, causing an infinite render loop.

To Reproduce
Steps to reproduce the behavior:

  1. Create a local frontend & backend
  2. Create a new page and save it
  3. View the classic UI/ backend edit view for the newly created page, open the "layout" tab and delete all strings from within the "items" JSON key in the Blocks Layout text field.
  4. Save the page and view the frontend again
  5. See that the frontend in view mode works fine (it will display nothing)
  6. Try to open 'edit' mode
  7. The page will either display a React max recursion error (Volto 16) or the tab/ browser will become unresponsive without any error.

Expected behavior
The page displays nothing

Software (please complete the following information):

  • OS: [e.g. iOS] All
  • Browser [e.g. firefox, chrome, safari] All
  • Volto Version [e.g. 18.4.0] 16.x - 18.8.4
  • Plone Version [e.g. 6.1.0] 6.0/ 6.1
  • Plone REST API Version [e.g. 9.1.0] N/A

Additional context

While this is a bit of an odd state to get in to, there are many ways it could happen (editors/ developers deleting the key, bad code rollout, addon misbehaving, etc.) and having the page silently crash and cause the user device to become unresponsive is highly undesirable.

@JeffersonBledsoe JeffersonBledsoe added 01 type: bug 30 needs: triage New issue that needs confirmation before work begins labels Feb 10, 2025
@boss6825
Copy link
Member

boss6825 commented Feb 12, 2025

Looking into the infinite loop caused by onChangeFormData during render cycles in BlocksForm. Seems like moving the invalid block cleanup to a useEffect might stabilize the state updates.
Will try to fix it....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
01 type: bug 30 needs: triage New issue that needs confirmation before work begins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants