Cocos Creator 3.3.1 Duplicate keys detected: This may cause an update error

Hi all. In current version of Cocos I usually see such error when create a lot of nodes from prefabs. After this my nodes stuck in editor and require editor restart, but then comes again:

Video:

I can ask engineering to review this.

I noticed it happens when I create a node in editor by @executeInEditMode decorator…
I gave up and just created nodes inside prefab manually… and change its active in @excuteInEditMode:

These two nodes previously were created depend on cellType property.
image

enum CellType {
	Ground,
	High,
	None,
}

@ccclass('CellTypeNodes')
class CellTypeNodes {
	@property(Node)
	Ground: Node = null;

	@property(Node)
	High: Node = null;
}

@ccclass('CellBasicComponent')
@executeInEditMode()
export class CellBasicComponent extends Component {
	@property(CellTypeNodes)
	private cellNodes: CellTypeNodes = new CellTypeNodes();

	@property
	private _cellType: CellType = CellType.None;

	private _lastActiveNode: Node = null;

	@property({ type: Enum(CellType) })
	get cellType() {
		return this._cellType;
	}

	set cellType(value: CellType) {
		this._cellType = value;

		this.updateCell();
	}

	protected onLoad() {
		const { cellNodes, cellType } = this;

		if (!EDITOR) {
			for (const key in cellNodes) {
				if (key !== CellType[cellType]) {
					cellNodes[key].removeFromParent();
					cellNodes[key].destroy();
				}
			}

			cellNodes[CellType[cellType]].active = true;
		} else {
			this.updateCell();
		}
	}

	private updateCell() {
		const { node, cellType, cellNodes } = this;

		this._lastActiveNode && (this._lastActiveNode.active = false);

		if (cellType === CellType.None) {
			return;
		}

		cellNodes[CellType[cellType]].active = true;

		this._lastActiveNode = cellNodes[CellType[cellType]];
	}
}

My code like this now…

Also, this error happens when I copy and paste prefab in the scene… I switched version to the 3.3.2, but still bug with copy&paste and when I create nodes in @executeInEditMode

I confirmed the issue and I was able to reproduce the issue you mentioned on 3.3.2. We have solved this issue in 3.4.0, I tested with 3.4.0 which is not yet released internally and this issue does not exist.

This should be related to the data copy, the data inside the scene file is confused. It may not have anything to do with the use of @executeInEditMode. I’m using just nodes and components to test.

I think the problem in prefabs… You can look my another topic, I explained a lot of issues: