Skip to content

fix(server): add error logging to catch {} in MCP server.zig message processing #189

Description

@gHashTag

Task

In tools/mcp/trinity_mcp/server.zig, critical message processing errors are silently swallowed:

  • Line 1195: _ = posix.write(stderr_fd, "TRINITY MCP Server v2.0.0 started\n") catch {};
  • Line 1196: _ = posix.write(stderr_fd, "38+ tools + resources + prompts | Content-Length framing\n\n") catch {};
  • Line 1226: processMessage(&server, line, &stdout_writer, allocator) catch {};
  • Line 1272: processMessage(&server, body, &stdout_writer, allocator) catch {};

Lines 1226 and 1272 are especially critical — silently dropping MCP messages means tools fail with no indication why.

Fix

For startup messages (1195-1196), these are non-critical — add a comment:

// Best-effort: stderr may not be available
_ = posix.write(stderr_fd, "...") catch {};

For message processing (1226, 1272), log the error:

processMessage(&server, line, &stdout_writer, allocator) catch |err| {
    std.log.err("MCP message processing failed: {s}", .{@errorName(err)});
};

File

  • tools/mcp/trinity_mcp/server.zig — lines 1195, 1196, 1226, 1272

Acceptance

  • zig build compiles without errors
  • zig fmt passes
  • processMessage errors are logged, startup writes have comments

Activity

  1. github-actions commented on Mar 11, 2026

    @github-actions
    Contributor

    🚀 Agent container spawned! Deploying on Railway. Tracking in this issue.

  2. github-actions commented on Mar 11, 2026

    @github-actions
    Contributor

    🚀 Agent container spawned! Deploying on Railway. Tracking in this issue.

  3. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    🌅 Trinity Agent | 2026-03-11T19:30:38Z
    📋 Step: 1/8 — Authenticating with GitHub
    🔄 Status: AWAKENING
    ⏱️ Elapsed: 0s

  4. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    🌅 Trinity Agent Dashboard — Issue #189

    Field Value
    Status AWAKENING
    Step 1/8
    Detail Authenticating with GitHub
    Elapsed 0s
    Container agent-189
    Updated 2026-03-11T19:30:38Z
  5. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    🌅 Trinity Agent Dashboard — Issue #189

    Field Value
    Status AWAKENING
    Step 2/8
    Detail Creating worktree from bare repository
    Elapsed 3s
    Container agent-189
    Updated 2026-03-11T19:30:41Z
  6. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    ☠️ Trinity Agent | 2026-03-11T19:30:46Z
    📋 Step: 3/8 — Container terminated by signal
    🔄 Status: KILLED
    ⏱️ Elapsed: 8s

  7. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    ☠️ Trinity Agent Dashboard — Issue #189

    Field Value
    Status KILLED
    Step 3/8
    Detail Container terminated by signal
    Elapsed 8s
    Container agent-189
    Updated 2026-03-11T19:30:46Z
  8. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    🌅 Trinity Agent | 2026-03-11T19:30:52Z
    📋 Step: 1/8 — Authenticating with GitHub
    🔄 Status: AWAKENING
    ⏱️ Elapsed: 0s

  9. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    🌅 Trinity Agent Dashboard — Issue #189

    Field Value
    Status AWAKENING
    Step 1/8
    Detail Authenticating with GitHub
    Elapsed 0s
    Container agent-189
    Updated 2026-03-11T19:30:52Z
  10. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    ☠️ Trinity Agent | 2026-03-11T19:30:54Z
    📋 Step: 2/8 — Container terminated by signal
    🔄 Status: KILLED
    ⏱️ Elapsed: 2s

  11. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    ☠️ Trinity Agent Dashboard — Issue #189

    Field Value
    Status KILLED
    Step 2/8
    Detail Container terminated by signal
    Elapsed 2s
    Container agent-189
    Updated 2026-03-11T19:30:54Z
  12. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    🌅 Trinity Agent | 2026-03-11T19:30:58Z
    📋 Step: 1/8 — Authenticating with GitHub
    🔄 Status: AWAKENING
    ⏱️ Elapsed: 0s

  13. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    🌅 Trinity Agent Dashboard — Issue #189

    Field Value
    Status AWAKENING
    Step 1/8
    Detail Authenticating with GitHub
    Elapsed 0s
    Container agent-189
    Updated 2026-03-11T19:30:58Z
  14. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    ☠️ Trinity Agent | 2026-03-11T19:31:01Z
    📋 Step: 2/8 — Container terminated by signal
    🔄 Status: KILLED
    ⏱️ Elapsed: 3s

  15. 1 remaining item

  16. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    🌅 Trinity Agent | 2026-03-11T19:31:06Z
    📋 Step: 1/8 — Authenticating with GitHub
    🔄 Status: AWAKENING
    ⏱️ Elapsed: 0s

  17. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    🌅 Trinity Agent Dashboard — Issue #189

    Field Value
    Status AWAKENING
    Step 1/8
    Detail Authenticating with GitHub
    Elapsed 0s
    Container agent-189
    Updated 2026-03-11T19:31:06Z
  18. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    🌅 Trinity Agent Dashboard — Issue #189

    Field Value
    Status AWAKENING
    Step 2/8
    Detail Creating worktree from bare repository
    Elapsed 4s
    Container agent-189
    Updated 2026-03-11T19:31:10Z
  19. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    ✅ Trinity Agent Dashboard — Issue #189

    Field Value
    Status DONE
    Step 8/8
    Detail PR created with 1 commits
    Elapsed 255s
    Container agent-189
    Updated 2026-03-11T19:35:21Z
  20. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    📖 Trinity Agent Dashboard — Issue #189

    Field Value
    Status READING
    Step 3/8
    Detail Reading issue #189
    Elapsed 8s
    Container agent-189
    Updated 2026-03-11T19:31:14Z
  21. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    ⚡ Trinity Agent | 2026-03-11T19:31:18Z
    📋 Step: 4/8 — Claude Code running (timeout: 3600s)
    🔄 Status: CODING
    ⏱️ Elapsed: 12s

  22. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    🔧 Agent: Claude | 2026-03-11
    📋 Step: 1/1 — Implement error logging fix
    🔄 Status: DONE

    Thought: Silent catch {} blocks were dropping MCP message processing errors with no visibility for debugging.

    Action:

    • Added comment to stderr startup writes (lines 1167-1168) documenting them as best-effort
    • Added std.log.err logging for both processMessage calls (lines 1198, 1246)

    Result:

    Next: Merge PR, issue auto-closes

  23. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    💥 Trinity Agent | 2026-03-11T19:35:00Z
    📋 Step: 5/8 — 2. Lines 1198-1200 - Added error logging for raw JSON message processing:
    🔄 Status: ERROR
    ⏱️ Elapsed: 234s

  24. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    🔄 Trinity Agent | 2026-03-11T19:35:09Z
    📋 Step: 5/8 — Self-review (advisory)
    🔄 Status: REVIEWING
    ⏱️ Elapsed: 243s

  25. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    🧪 Trinity Agent | 2026-03-11T19:35:14Z
    📋 Step: 6/8 — Checking/creating PR
    🔄 Status: TESTING
    ⏱️ Elapsed: 248s

  26. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    🚀 Trinity Agent | 2026-03-11T19:35:18Z
    📋 Step: 7/8 — PR #191 already exists
    🔄 Status: PR_CREATED
    ⏱️ Elapsed: 252s

  27. gHashTag commented on Mar 11, 2026

    @gHashTag
    OwnerAuthor

    ✅ Trinity Agent | 2026-03-11T19:35:21Z
    📋 Step: 8/8 — PR created with 1 commits
    🔄 Status: DONE
    ⏱️ Elapsed: 255s

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:spawnAuto-spawn agent container

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions