PostMessageTransport: make debug logging opt-in (or accept a logger)
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
- Lĩnh vực
- developer-experience, tooling
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.errortoconsole.debug. - #546 skipped the log for
tool-input-partialbecause 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
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/ext-apps
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
modelcontextprotocol/ext-apps#767 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
modelcontextprotocol/ext-apps#742 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
modelcontextprotocol/ext-apps#711 ·
-
Spec: Deprecate Sampling Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
modelcontextprotocol/ext-apps#706 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
modelcontextprotocol/ext-apps#703 · 1 reaction ·
Tất cả issue của modelcontextprotocol/ext-apps
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
vercel-labs/just-bash#464 ·
-
looksLikeSlug() is ASCII-only, so non-Latin entity slugs (e.g. Korean) skip exact match and collapse Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
TanStack/tanstack.com#1293 ·