Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

PostMessageTransport: make debug logging opt-in (or accept a logger)

Đang mở Phù hợp với người mới
#786 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
70/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript

Hướng nghiên cứu

Issue trỏ đến src/message-transport.ts, cụ thể là các dòng gọi console.debug. Bắt đầu bằng cách kiểm tra hàm khởi tạo PostMessageTransport và chữ ký hiện tại của nó. Nhiệm vụ là thêm một đối số thứ ba tùy chọn cho một logger, mặc định là không ghi log. Kiểm tra cách transport được khởi tạo ở những nơi khác trong codebase để đảm bảo khả năng tương thích ngược. Viết một bài kiểm tra để xác minh rằng việc ghi log chỉ xảy ra khi một logger được cung cấp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Problem

PostMessageTransport calls console.debug unconditionally (src/message-transport.ts at 264d9ca, lines 77, 82, 87 and 128):

  • "Sending message" for every outgoing message except tool-input-partial
  • "Parsed message" for every valid incoming message
  • "Ignoring message from unknown source" for every message from another frame

A host cannot turn these off. The transport takes no option for it, and the only workaround is wrapping console.debug globally.

The noise grows with the number of Apps on a page. Each card's host transport listens on the same window, so a message from any View reaches every bridge. The owning bridge logs "Parsed message", and each of the other N−1 bridges logs "Ignoring message from unknown source" with the full MessageEvent. With four cards in a conversation, every View message produces four host lines, plus the View's own "Sending message" inside its frame. Size changes and host-context updates fan out the same way.

The source check is correct. Only the logging is the problem.

Prior discussion

  • #237 / #239 moved the unknown-source log from console.error to console.debug.
  • #546 skipped the log for tool-input-partial because it flooded the console.
  • #741 asked for opt-in logging or a configurable logger, and noted that full payloads, including tool-result _meta, reach the console. Its filer closed it without a change.

Proposal

Make transport logging opt-in through an options argument:

new PostMessageTransport(eventTarget, eventSource, { logger?: Pick<Console, "debug"> })

Log nothing when logger is absent. The console.error for a malformed JSON-RPC message can stay. The third argument keeps the existing constructor compatible.

Happy to open a PR if this direction works.

Seen on 1.7.5; unchanged on main as of v2.0.0.

Ngôn ngữ chính
TypeScript
Star
2.9k
Fork
387
Merge trung bình
2 giờ 54 phút
Pull request đã merge (30 ngày)
7

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelcontextprotocol/ext-apps

Tất cả issue của modelcontextprotocol/ext-apps

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.