--- id: messages---comfyui title: "Messages - ComfyUI" category: "10_Wiki/Topics" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: [] duplicate_of: "" source_trust_level: "B" confidence_score: 0.8 created_at: 2026-05-20 updated_at: 2026-05-20 review_reason: "" merge_history: [] tags: ["web", "wikify"] raw_sources: ["https://docs.comfy.org/development/comfyui-server/comms_messages"] applied_in: [] github_commit: "" --- # [[Messages - ComfyUI]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) [[ComfyUI]] μ„œλ²„μ™€ ν΄λΌμ΄μ–ΈνŠΈ κ°„μ˜ μ‹€μ‹œκ°„ 데이터 κ΅ν™˜μ„ μœ„ν•΄ [[PromptExecutor]]κ°€ [[PromptServer]]λ₯Ό 톡해 λ©”μ‹œμ§€λ₯Ό μ „μ†‘ν•˜κ³ , ν΄λΌμ΄μ–ΈνŠΈλŠ” μ†ŒμΌ“ 이벀트λ₯Ό 톡해 이λ₯Ό μˆ˜μ‹ ν•˜μ—¬ μ²˜λ¦¬ν•˜λŠ” 톡신 λ©”μ»€λ‹ˆμ¦˜. ## 🧠 핡심 κ°œλ… (Core concepts) - **λ©”μ‹œμ§€ 전달 ꡬ쑰**: [[PromptExecutor]]κ°€ μ‹€ν–‰ 쀑 λ˜λŠ” 큐 μƒνƒœ λ³€κ²½ μ‹œ [[PromptServer]]의 `send_sync` λ©”μ„œλ“œλ₯Ό 톡해 ν΄λΌμ΄μ–ΈνŠΈλ‘œ λ©”μ‹œμ§€λ₯Ό 전솑함. - **ν΄λΌμ΄μ–ΈνŠΈ μˆ˜μ‹  방식**: [[api.js]]에 μ •μ˜λœ μ†ŒμΌ“ 이벀트 λ¦¬μŠ€λ„ˆκ°€ `CustomEvent` 객체λ₯Ό μƒμ„±ν•˜μ—¬ λ“±λ‘λœ λ¦¬μŠ€λ„ˆλ‘œ λ””μŠ€νŒ¨μΉ˜ν•¨. - **ν™•μž₯μ„± (Extensibility)**: κΈ°λ³Έ μ œκ³΅λ˜λŠ” λ©”μ‹œμ§€ νƒ€μž… 외에도 ν΄λΌμ΄μ–ΈνŠΈμ™€ μ„œλ²„ μ–‘μΈ‘μ—μ„œ μ‚¬μš©μž μ •μ˜ λ©”μ‹œμ§€ νƒ€μž…μ„ μΆ”κ°€ν•˜κ³  μ²˜λ¦¬ν•  수 있음. - **데이터 ꡬ쑰**: λ©”μ‹œμ§€ ν•Έλ“€λŸ¬λŠ” `CustomEvent`λ₯Ό 톡해 μ „λ‹¬λ°›μœΌλ©°, `.detail` 속성을 톡해 μ„œλ²„κ°€ 보낸 데이터 λ”•μ…”λ„ˆλ¦¬μ— μ ‘κ·Ό κ°€λŠ₯함. ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **이벀트 기반 톡신**: ν΄λΌμ΄μ–ΈνŠΈ μΈ‘μ—μ„œ `api.addEventListener(message_type, messageHandler)` ν˜•μ‹μ„ μ‚¬μš©ν•˜μ—¬ νŠΉμ • λ©”μ‹œμ§€ νƒ€μž…μ— λŒ€ν•œ 이벀트λ₯Ό λ“±λ‘ν•˜λŠ” ν‘œμ€€ JavaScript κ΄€μš©κ΅¬ μ‚¬μš©. - **μžλ™ μœ ν˜• 인식**: μ •μ˜λ˜μ§€ μ•Šμ€ μƒˆλ‘œμš΄ λ©”μ‹œμ§€ νƒ€μž…μ΄ λ“€μ–΄μ˜€λ©΄ ν΄λΌμ΄μ–ΈνŠΈλŠ” 이λ₯Ό μžλ™μœΌλ‘œ μ•Œλ €μ§„ λ©”μ‹œμ§€ λͺ©λ‘μ— 좔가함. o **μ„œλ²„-ν΄λΌμ΄μ–ΈνŠΈ 동기화**: μ„œλ²„ μΈ‘μ—μ„œλŠ” `PromptServer.instance.send_sync`λ₯Ό 톡해, ν΄λΌμ΄μ–ΈνŠΈ μΈ‘μ—μ„œλŠ” λ¦¬μŠ€λ„ˆ 등둝을 톡해 μ–‘λ°©ν–₯ 톡신 ꡬ쑰λ₯Ό ν˜•μ„±ν•¨. ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) ### 1. λ‚΄μž₯ λ©”μ‹œμ§€ νƒ€μž… (Built in message types) [[PromptServer]]의 `send_sync` λ©”μ„œλ“œλ₯Ό 톡해 μ „λ‹¬λ˜λŠ” μ£Όμš” μ΄λ²€νŠΈμ™€ κ·Έ 데이터 ꡬ성은 λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€. | event | when data | | :--- | :--- | | execution_start | When a prompt is about to run: `prompt_id` | | execution_error | When an error occurs during execution: `prompt_id`, plus additional information | | execution_interrupted | When execution is stopped by a node raising `InterruptProcessingException`: `prompt_id`, `node_id`, `node_type` and executed (a list of executed nodes) | | execution_cached | At the start of execution: `prompt_id`, `nodes` (a list of nodes which are being skipped because their cached outputs can be used) | | execution_success | When all nodes from the prompt have been successfully executed: `prompt_id`, `timestamp` | | executing | When a new node is about to be executed: `node` (node id or None to indicate completion), `prompt_id` | | executed | When a node returns a ui element: `node` (node id), `prompt_id`, `output` | | progress | During execution of a node that implements the required hook: `node` (node id), `prompt_id`, `value`, `max` | | status | When the state of the queue changes: `exec_info`, a dictionary holding `queue_remaining` (the number of entries in the queue) | ### 2. μ‹€ν–‰λœ λ©”μ‹œμ§€ ν™œμš© (Using executed) 'executed' λ©”μ‹œμ§€λŠ” λ‹¨μˆœνžˆ λ…Έλ“œκ°€ 싀행을 μ™„λ£Œν•  λ•Œ μ „μ†‘λ˜λŠ” 것이 μ•„λ‹ˆλΌ, **λ…Έλ“œκ°€ UI μ—…λ°μ΄νŠΈλ₯Ό λ°˜ν™˜ν•  λ•Œλ§Œ** μ „μ†‘λ©λ‹ˆλ‹€. 이λ₯Ό μœ„ν•΄ 메인 ν•¨μˆ˜λŠ” νŠœν”Œ λŒ€μ‹  λ‹€μŒκ³Ό 같은 ꡬ쑰의 λ”•μ…” Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ ν•©λ‹ˆλ‹€: - `return { "ui": a_new_dictionary, "result": the_tuple_of_output_values }` - `a_new_dictionary`λŠ” `output` κ°’μœΌλ‘œ μ „μ†‘λ˜λ©°, κ²°κ³Ό ν‚€(`result`)λŠ” 좜λ ₯값이 μ—†λŠ” 경우 μƒλž΅ κ°€λŠ₯ν•©λ‹ˆλ‹€. ### 3. μ‚¬μš©μž μ •μ˜ λ©”μ‹œμ§€ νƒ€μž… (Custom message types) - **ν΄λΌμ΄μ–ΈνŠΈ μΈ‘**: `api.addEventListener("my.custom.message", messageHandler);`와 같이 κ³ μœ ν•œ μ΄λ¦„μœΌλ‘œ λ¦¬μŠ€λ„ˆλ₯Ό λ“±λ‘ν•˜μ—¬ κ΅¬ν˜„ν•©λ‹ˆλ‹€. - **μ„œλ²„ μΈ‘**: `PromptServer.instance.send_sync("my.custom.message", a_dictionary)`λ₯Ό μ‚¬μš©ν•˜μ—¬ 데이터λ₯Ό μ „μ†‘ν•©λ‹ˆλ‹€. ### 4. λ…Έλ“œ ID νšλ“ (Getting node_id) λ‚΄μž₯ λ©”μ‹œμ§€μ—λŠ” ν˜„μž¬ λ…Έλ“œμ˜ IDκ°€ ν¬ν•¨λ˜λŠ” κ²½μš°κ°€ λ§ŽμŠ΅λ‹ˆλ‹€. μ„œλ²„ μΈ‘μ—μ„œ 이λ₯Ό ν™œμš©ν•˜κΈ° μœ„ν•΄ `INPUT_TYPES`의 `hidden` ν‚€λ₯Ό μ‚¬μš©ν•˜μ—¬ `node_id`λ₯Ό κ°€μ Έμ˜¬ 수 μžˆμŠ΅λ‹ˆλ‹€. ```python @classmethod def INPUT_TYPES(s): return {"required" : { }, "hidden": { "node_id": "UNIQUE_ID" } } ``` ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) λ³Έλ¬Έμ—μ„œ 'executed' λ©”μ‹œμ§€λΌλŠ” λͺ…μΉ­κ³Ό μ‹€μ œ λ™μž‘(UI μ—…λ°μ΄νŠΈκ°€ μžˆμ„ λ•Œλ§Œ 전솑됨) μ‚¬μ΄μ˜ 차이점에 λŒ€ν•΄ μ„€λͺ…ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. ## πŸ› οΈ 적용 사둀 (Applied in summary) - **μ»€μŠ€ν…€ λ…Έλ“œ 개발**: `INPUT_TYPES` λ‚΄ `hidden` 섀정을 톡해 μ„œλ²„ μΈ‘μ—μ„œ `node_id`λ₯Ό μ‹λ³„ν•˜κ³  이λ₯Ό λ©”μ‹œμ§€μ— ν¬ν•¨μ‹œμΌœ ν΄λΌμ΄μ–ΈνŠΈμ— μ „λ‹¬ν•˜λŠ” 사둀. - **ν™•μž₯ κΈ°λŠ₯(Extension) κ΅¬ν˜„**: `setup()` ν•¨μˆ˜ λ‚΄μ—μ„œ `api.addEventListener`λ₯Ό μ‚¬μš©ν•˜μ—¬ νŠΉμ • μ΄λ²€νŠΈμ— λŒ€ν•œ ν•Έλ“€λŸ¬λ₯Ό λ“±λ‘ν•˜λŠ” 사둀. ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (Primary Source β€” μ›Ήμ‚¬μ΄νŠΈ λ³Έλ¬Έ 직접 μΆ”μΆœ) - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— κ΄€λ ¨ λ¬Έμ„œ 링크 (Related document links) - [[PromptExecutor]]: λ©”μ‹œμ§€λ₯Ό ν΄λΌμ΄μ–ΈνŠΈλ‘œ μ „μ†‘ν•˜λŠ” 주체. - [[PromptServer]]: `send_sync` λ©”μ„œλ“œλ₯Ό 톡해 λ©”μ‹œμ§€ 전달을 λ‹΄λ‹Ήν•˜λŠ” μ„œλ²„ ꡬ성 μš”μ†Œ. - [[api.js]]: μ†ŒμΌ“ 이벀트 λ¦¬μŠ€λ„ˆκ°€ μ •μ˜λ˜μ–΄ μžˆλŠ” ν΄λΌμ΄μ–ΈνŠΈ μΈ‘ 핡심 파일. - [[InterruptProcessingException]]: μ‹€ν–‰ 쀑단 μ‹œ λ°œμƒν•˜λŠ” μ˜ˆμ™Έ νƒ€μž…. - [[INPUT_TYPES]]: λ…Έλ“œμ˜ μž…λ ₯ νƒ€μž…μ„ μ •μ˜ν•˜λ©° `node_id`λ₯Ό μˆ¨κ²¨μ§„ κ°’μœΌλ‘œ κ°€μ Έμ˜€λŠ” 데 μ‚¬μš©λ¨. ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-05-20: Astra /wikify 둜 https://docs.comfy.org/development/comfyui-server/comms_messages λ³Έλ¬Έμ—μ„œ μ΄ˆμ•ˆ 생성.