Comfy-Org / Comfy-Org/ComfyUI

Optimize the event logic for WebSocket transmissions.

Open
#8,248 0 comments 0 reactions 0 assignees View on GitHub
Feature
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 10h
Merged PRs (30d)
153

Description

### Feature Idea

We are currently using WebSocket messages to monitor the execution status of nodes and output the results to OTEL.

1. [execution_start](https://github.com/comfyanonymous/ComfyUI/blob/master/execution.py#L496) -> the beginning of a prompt.
2. [execution_error](https://github.com/comfyanonymous/ComfyUI/blob/master/execution.py#L485) -> the failure of prompt
3. [execution_success](https://github.com/comfyanonymous/ComfyUI/blob/master/execution.py#L538) -> the success of prompt

4. [executing](https://github.com/comfyanonymous/ComfyUI/blob/master/execution.py#L311) -> the begining of a node

The problem is that there’s no way to detect when a node finishes execution.
[executed](https://github.com/comfyanonymous/ComfyUI/blob/master/execution.py#L361) is only sent when there are ui changes.
Additionally, when a cache hit occurs, the [executed](https://github.com/comfyanonymous/ComfyUI/blob/master/execution.py#L281)
message is also sent, but there are no additional fields to distinguish it.

Our current approach is to treat the start of a new node as the end of the previous one.

We hope to achieve the following:
• Send the executed message regardless of whether there are UI changes.
• Include a way for listeners to distinguish whether a cache hit occurred.

### Existing Solutions

_No response_

### Other

_No response_

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.