Skip to content

Sockets are not removed from the DOM #731

@rockit666

Description

@rockit666

Describe the bug

Hi,

I'm using NX with Angular 19, Vite, and Standalone Components.
I'm using a JSON file to create the diagram.

Everything works fine as expected — exactly like in the examples.

However, when I retry the process, it seems that the sockets are not being removed from the DOM.
I've tried every possible combination, including disabling HMR, and so on.

Thanks a lot for your help!

Greets,
Frank

Error in PROD:
Found more than one element for socket with same key and side. Probably it was not unmounted correctly {side: 'output', nodeId: 'cb447c3c89d40d32', key: 'trigger-out'}
chunk-7EZH3TMK.js:13
arg1 =
{side: 'output', nodeId: 'cb447c3c89d40d32', key: 'trigger-out'}
value @ c:\Data\Repros\Barracuda-AI\Frontend\Barracuda-UI\chunk-7EZH3TMK.js:13:1234

Error in DEV:
Found more than one element for socket with same key and side. Probably it was not unmounted correctly {side: 'output', nodeId: 'cb447c3c89d40d32', key: 'trigger-out'}

This is my code to remove all items:

private async deleteItems(): Promise<any> {
  if (this.editor) { 
    await this.deleteConnections();       
    await this.deleteNodes();

    if (await this.editor.clear()) {
      // No error
    }
    
  }
}

private async deleteConnections(): Promise<any>  {
  const connections = this.editor!.getConnections();
  if (connections) {      
    for (const connection of connections) {
        await this.editor!.removeConnection(connection.id);
    }
  }
}

private async deleteNodes(): Promise<any>  {
  const nodes = this.editor!.getNodes();
  if (nodes) {      
    for (const node of nodes) {
  
        Object.keys(node.inputs).forEach(key => {
          node.removeInput(key);
        });

        Object.keys(node.outputs).forEach(key => {
          node.removeOutput(key);
        });
        
        await this.editor!.removeNode(node.id);
    }
  }
}

Example to reproduce

No response

How to reproduce

Expected behavior

Sockets should be removed from the DOM when a node is deleted.

Dependencies

├── @angular-devkit/[email protected]
├── @angular-devkit/[email protected]
├── @angular-devkit/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @eslint/[email protected]
├── @jsverse/[email protected]
├── @nx/[email protected]
├── @nx/[email protected]
├── @nx/[email protected]
├── @nx/[email protected]
├── @nx/[email protected]
├── @nx/[email protected]
├── @primeng/[email protected]
├── @schematics/[email protected]
├── @swc-node/[email protected]
├── @swc/[email protected]
├── @swc/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @typescript-eslint/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Platform

Chrome Version 135.0.7049.115 (Offizieller Build) (64-Bit)

Relevant log output

The source of the error message is: rete-editor.service.ts

  return _createClass(SocketsPositionsStorage, [{
    key: "getPosition",
    value: function getPosition(data) {
      var _found$pop$position, _found$pop;
      var list = Array.from(this.elements.values()).flat();
      var found = list.filter(function (item) {
        return item.side === data.side && item.nodeId === data.nodeId && item.key === data.key;
      });

      // eslint-disable-next-line no-console
      if (found.length > 1) console.warn(['Found more than one element for socket with same key and side.', 'Probably it was not unmounted correctly'].join(' '), data);
      return (_found$pop$position = (_found$pop = found.pop()) === null || _found$pop === void 0 ? void 0 : _found$pop.position) !== null && _found$pop$position !== void 0 ? _found$pop$position : null;
    }
  }

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions