Skip to content

fix: update emitter event matching logic#17

Open
bw31642 wants to merge 1 commit intolgazo:mainfrom
bw31642:emitter-fix
Open

fix: update emitter event matching logic#17
bw31642 wants to merge 1 commit intolgazo:mainfrom
bw31642:emitter-fix

Conversation

@bw31642
Copy link
Copy Markdown

@bw31642 bw31642 commented Aug 15, 2025

Fix for get-shape-categories Tool Hanging Issue

Problem Description

The get-shape-categories MCP tool call was hanging indefinitely instead of returning the shape categories from Draw.io. This issue affected the tool's ability to retrieve available shape categories from the diagram's library.

Root Cause Analysis

The issue was located in the reply matching logic within the emitter_bus.ts file. Here's what was happening:

The Broken Flow

  1. Request Generation (tool.ts line 19):

    const reply_name = `${event_name}.${request_id}`;
    // Example: "get-shape-categories.abc123"
  2. Request Sent to Extension:

    {
      "__event": "get-shape-categories",
      "__request_id": "abc123"
    }
  3. Extension Response:

    {
      "__event": "get-shape-categories",
      "__request_id": "abc123",
      "categories": [...]
    }
  4. Failed Reply Matching (emitter_bus.ts line 21):

    if (emitter_data && emitter_data.__event === event_name) {

    This was comparing:

    • emitter_data.__event: "get-shape-categories"
    • event_name: "get-shape-categories.abc123"

    Result: No match → Promise never resolves → Tool hangs

The Fix

File Modified: ./src/emitter_bus.ts

Before (lines 18-24):

on_reply_from_extension: (event_name, reply) => {
  const listener = (emitter_data: any) => {
    log.debug(`[bus] received from Extension`, emitter_data);
    if (emitter_data && emitter_data.__event === event_name) {
      reply(emitter_data);
    }
  };
  emitter.on(bus_reply_stream, listener);
  listeners.push(reply);
},

After (lines 18-24):

on_reply_from_extension: (event_name, reply) => {
  const listener = (emitter_data: any) => {
    log.debug(`[bus] received from Extension`, emitter_data);
    if (emitter_data && emitter_data.__request_id && event_name.endsWith(emitter_data.__request_id)) {
      reply(emitter_data);
    }
  };
  emitter.on(bus_reply_stream, listener);
  listeners.push(reply);
},

What Changed

The matching condition was changed from:

emitter_data.__event === event_name

To:

emitter_data.__request_id && event_name.endsWith(emitter_data.__request_id)

@lgazo
Copy link
Copy Markdown
Owner

lgazo commented Aug 16, 2025

Hi @bw31642,
can you elaborate more on the issue itself? The fix you're proposing is not in line with the way how the communication protocol is designed. I assume the issue lies somewhere else. What version of Extension and Server do you use? What kind of client do you use?

The reason why I think the fix is not correct is, that the Extension builds proper event name in on_standard_tool_request_from_server, which is used by the mentioned tool. The PR looks like being built by AI without wider understanding of the context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants