PostMessageTransport: make debug logging opt-in (or accept a logger)
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 70/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
该 issue 指向 src/message-transport.ts,特别是调用 console.debug 的代码行。首先检查 PostMessageTransport 构造函数及其当前的签名。任务是为 logger 添加一个可选的第三个参数,默认不进行日志记录。检查代码库中其他位置如何实例化该传输,以确保向后兼容性。编写一个测试来验证仅当提供了 logger 时才进行日志记录。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- TypeScript
- 星标
- 2.9k
- 派生
- 387
- 平均合并
- 2 小时 54 分钟
- 30 天内合并 PR
- 7
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/ext-apps 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
modelcontextprotocol/ext-apps#767 ·
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
modelcontextprotocol/ext-apps#742 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 72/100
modelcontextprotocol/ext-apps#711 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
modelcontextprotocol/ext-apps#706 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
modelcontextprotocol/ext-apps#703 · 1 个 reaction ·
查看 modelcontextprotocol/ext-apps 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
mksglu/context-mode#1200 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
难度 2/5 1-3 小时 新手友好度 75/100
anthropics/claude-code#96687 ·
-
good first issue
难度 1/5 1 小时以内 新手友好度 95/100
AOSSIE-Org/DebateAI#582 · 2 条评论 ·