TanStack / TanStack/devtools

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

オープン
#435 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
TypeScript
スター
499
フォーク
100
平均マージ
1日 17時間
マージ済み PR(30日)
4

説明

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

  • @tanstack/devtools-vite@0.6.0
  • Vite 8
  • TanStack Start
  • Node 18+

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

packages/devtools-vite/src/virtual-console.ts から始め、server prefix と transformedArgs を指定して logMethod.apply を呼び出すブラウザ側の handler を調べます。devtools Vite plugin を使用する TanStack Start アプリで、Nitro のリクエストログを使って問題を再現します。ブラウザコンソールで printf-style のプレースホルダーがリテラルトークンとして表示されるのではなく、正しく置換されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript, vite
領域
devtools
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
72/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。