mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-03-15 06:07:33 +08:00
fix: always send new binary format when client supports feature flag
When prompt_id is None, encode as zero-length string instead of falling back to old format. Prevents binary parse corruption on the frontend. Addresses review feedback: https://github.com/Comfy-Org/ComfyUI/pull/12540#discussion_r2923412491
This commit is contained in:
parent
09e9bdbcad
commit
69d3bfa391
14
server.py
14
server.py
@ -1242,8 +1242,9 @@ class PromptServer():
|
|||||||
"""Send a progress text message to the client via WebSocket.
|
"""Send a progress text message to the client via WebSocket.
|
||||||
|
|
||||||
Encodes the text as a binary message with length-prefixed node_id. When
|
Encodes the text as a binary message with length-prefixed node_id. When
|
||||||
prompt_id is provided and the client supports the ``supports_progress_text_metadata``
|
the client supports the ``supports_progress_text_metadata`` feature flag,
|
||||||
feature flag, the prompt_id is prepended as an additional length-prefixed field.
|
the prompt_id is always prepended as a length-prefixed field (empty string
|
||||||
|
when None) to ensure consistent binary framing.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
text: The progress text content to send.
|
text: The progress text content to send.
|
||||||
@ -1258,12 +1259,13 @@ class PromptServer():
|
|||||||
# Auto-resolve sid to the currently executing client
|
# Auto-resolve sid to the currently executing client
|
||||||
target_sid = sid if sid is not None else self.client_id
|
target_sid = sid if sid is not None else self.client_id
|
||||||
|
|
||||||
# When prompt_id is available and client supports the new format,
|
# When client supports the new format, always send
|
||||||
# prepend prompt_id as a length-prefixed field before node_id
|
# [prompt_id_len][prompt_id][node_id_len][node_id][text]
|
||||||
if prompt_id and feature_flags.supports_feature(
|
# even when prompt_id is None (encoded as zero-length string)
|
||||||
|
if feature_flags.supports_feature(
|
||||||
self.sockets_metadata, target_sid, "supports_progress_text_metadata"
|
self.sockets_metadata, target_sid, "supports_progress_text_metadata"
|
||||||
):
|
):
|
||||||
prompt_id_bytes = prompt_id.encode("utf-8")
|
prompt_id_bytes = (prompt_id or "").encode("utf-8")
|
||||||
message = (
|
message = (
|
||||||
struct.pack(">I", len(prompt_id_bytes))
|
struct.pack(">I", len(prompt_id_bytes))
|
||||||
+ prompt_id_bytes
|
+ prompt_id_bytes
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user