From 69d3bfa391b3710b48f7458d99d624d8c3ae76a6 Mon Sep 17 00:00:00 2001 From: bymyself Date: Thu, 12 Mar 2026 09:20:52 -0700 Subject: [PATCH] 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 --- server.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/server.py b/server.py index 608c98d45..97ebf476c 100644 --- a/server.py +++ b/server.py @@ -1242,8 +1242,9 @@ class PromptServer(): """Send a progress text message to the client via WebSocket. 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`` - feature flag, the prompt_id is prepended as an additional length-prefixed field. + the client supports the ``supports_progress_text_metadata`` feature flag, + the prompt_id is always prepended as a length-prefixed field (empty string + when None) to ensure consistent binary framing. Args: text: The progress text content to send. @@ -1258,12 +1259,13 @@ class PromptServer(): # Auto-resolve sid to the currently executing client target_sid = sid if sid is not None else self.client_id - # When prompt_id is available and client supports the new format, - # prepend prompt_id as a length-prefixed field before node_id - if prompt_id and feature_flags.supports_feature( + # When client supports the new format, always send + # [prompt_id_len][prompt_id][node_id_len][node_id][text] + # 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" ): - prompt_id_bytes = prompt_id.encode("utf-8") + prompt_id_bytes = (prompt_id or "").encode("utf-8") message = ( struct.pack(">I", len(prompt_id_bytes)) + prompt_id_bytes