Server log pipe drops printf-style format substitution, leaks raw `%s` into browser console
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- TypeScript
- Estrellas
- 499
- Forks
- 100
- Merge medio
- 1 d 17 h
- PR fusionados (30 d)
- 4
Descripción
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.formaton 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+
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en packages/devtools-vite/src/virtual-console.ts e inspecciona el handler del lado del navegador que llama a logMethod.apply con el prefijo del servidor y transformedArgs. Reproduce el problema con un registro de solicitud de Nitro en una aplicación de TanStack Start usando el plugin Vite de devtools. Se considera terminado cuando los marcadores de posición de estilo printf se sustituyen correctamente en la consola del navegador en lugar de aparecer como tokens literales.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript, vite
- Área
- devtools
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Tranquilo
- Claridad
- Bien especificado
- Aptitud para principiantes
- 72/100