Comfy-Org / Comfy-Org/ComfyUI_frontend

When create a new node by alt dragging a node, create node is called twice

Open
#8,144 6 comments 0 reactions 0 assignees View on GitHub
area:litegraph area:nodes Potential Bug
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

### Prerequisites

- [x] I am running the latest version of ComfyUI
- [x] I have searched existing issues to make sure this isn't a duplicate
- [x] I have tested with all custom nodes disabled ([see how](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled))

### What happened?

I just noticed when debugging my api event listeners. I have a log right at the beginning:

```
const onNodeCreated = nodeType.prototype.onNodeCreated;
nodeType.prototype.onNodeCreated = function() {
onNodeCreated?.apply(this, arguments);

console.log("NODE CREATED", arguments)
```

It's creating it twice, which adds event listeners which get triggered and this.id === -1

But if it's going to call it, even if it only exists for a second, it should probably also trigger `this.onRemoved`

### Steps to Reproduce

1.
2.
3.

### How is this affecting you?

Minor inconvenience

### ComfyUI Frontend Version

1.36.14

### Browser

Chrome/Chromium

### Console Errors

```javascript

```

### Logs

```shell

```

### Additional Context

_No response_

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-8144-When-create-a-new-node-by-alt-dragging-a-node-create-node-is-called-twice-2ec6d73d3650817fa355dd751f35fccf) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.