Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Server log pipe drops printf-style format substitution, leaks raw `%s` into browser console

Offen
#435 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
72/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Ruhig
Tech-Stack
typescript, vite
Bereich
devtools

Rechercherichtung

Beginne in packages/devtools-vite/src/virtual-console.ts und untersuche den browserseitigen Handler, der logMethod.apply mit dem Serverpräfix und transformedArgs aufruft. Reproduziere das Problem mit einem Nitro-Request-Log in einer TanStack Start-App unter Verwendung des devtools Vite-Plugins. Erledigt ist die Aufgabe, wenn printf-style-Platzhalter in der Browserkonsole korrekt ersetzt werden, statt als Literal-Tokens zu erscheinen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

When server-side logs that use printf-style formatting (e.g. Nitro's request logger calling console.log('%s - %s info GET %s %d in %dms', ts, level, method, status, ms)) are piped to the browser via the virtual-console SSE bridge, the format substitution is lost and the literal %s tokens appear in the browser console.

Example output in browser:

[Server] %s - %s info GET /build-version 200 in 1ms

Cause

In packages/devtools-vite/src/virtual-console.ts, the browser-side handler reconstructs the call as:

var prefix = '%c[Server]%c';
logMethod.apply(console, [prefix, prefixStyle, resetStyle].concat(transformedArgs));

The browser console only treats the first argument as a format string. Since the prefix '%c[Server]%c' is now in position 0, the original server-side format string (which is at transformedArgs[0]) is no longer interpreted — its %s tokens print literally and the remaining args are appended as separate values rather than substituted.

Reproduction

Any TanStack Start app with devtools() in the Vite plugins. Hit any route while the dev server is running; the Nitro request log lands in the browser console with literal %s.

Suggested fix

Either:

  • (a) Pre-format the server args with util.format on the server before serializing, so the browser receives a single already-formatted string; or
  • (b) On the browser side, if transformedArgs[0] is a string containing format specifiers, merge it into the prefix format string (e.g. '%c[Server]%c ' + transformedArgs[0]) and shift the remaining args accordingly.

Environment

Vorherrschende Sprache
TypeScript
Sterne
499
Forks
100
Ø Merge
1 T. 17 Std.
Gemergte PRs (30 T.)
4

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus TanStack/devtools

Alle Issues in TanStack/devtools

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.