Skip to content

Commit

Permalink
BUGFIX: Remove race condition in watchNodeInformationChanges
Browse files Browse the repository at this point in the history
It may happen that `fetchAdditionalNodeMetadata` adds metadata for
a node that has since been removed from the store. The occurance
of such "zombie" nodes leads to problems, because they may lack
crucial properties like `children` that are treated as always-
present by other mechanisms throughout the UI.

This became apparent after #3756.

The CR.Nodes.MERGE action now takes care of preventing zombie nodes
from entering the store.
  • Loading branch information
grebaldi committed May 21, 2024
1 parent c9a48b5 commit fca73dd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/neos-ui-redux-store/src/CR/Nodes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,16 @@ export const reducer = (state: State = defaultState, action: InitAction | EditPr
if (!newNode) {
throw new Error('This error should never be thrown, it\'s a way to fool TypeScript');
}
const mergedNode = defaultsDeep({}, newNode, draft.byContextPath[contextPath]);
// Force overwrite of children
const oldNode = state.byContextPath[contextPath];
const mergedNode = defaultsDeep({}, newNode, oldNode);
if (newNode.children !== undefined) {
// Force overwrite of children
mergedNode.children = newNode.children;
} else if (!oldNode) {
// newNode only adds meta info, but oldNode is gone from the store.
// In order to avoid zombie nodes occupying the store, we'll leave
// the node alone in this case.
return;
}
// Force overwrite of matchesCurrentDimensions
if (newNode.matchesCurrentDimensions !== undefined) {
Expand Down

0 comments on commit fca73dd

Please sign in to comment.