Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#786 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

L'issue punta a src/message-transport.ts, in particolare alle righe in cui viene chiamato console.debug. Inizia esaminando il costruttore PostMessageTransport e la sua firma attuale. Il compito consiste nell'aggiungere un terzo argomento opzionale per un logger, che per impostazione predefinita non effettua alcuna registrazione. Controlla come il trasporto viene istanziato altrove nella codebase per garantire la compatibilità con le versioni precedenti. Scrivi un test per verificare che la registrazione avvenga solo quando viene fornito un logger.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
2.9k
Fork
387
Merge medio
2h 54m
PR unite (30g)
7

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di modelcontextprotocol/ext-apps

Tutte le issue di modelcontextprotocol/ext-apps

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.