Server log pipe drops printf-style format substitution, leaks raw `%s` into browser console
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- typescript, vite
- Lĩnh vực
- devtools
Hướng nghiên cứu
Bắt đầu trong packages/devtools-vite/src/virtual-console.ts và kiểm tra handler phía trình duyệt gọi logMethod.apply với server prefix và transformedArgs. Tái hiện issue bằng một Nitro request log trong một ứng dụng TanStack Start sử dụng devtools Vite plugin. Được xem là hoàn thành khi các placeholder theo kiểu printf được thay thế chính xác trong browser console thay vì hiển thị dưới dạng các token nguyên văn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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+
- Ngôn ngữ chính
- TypeScript
- Star
- 499
- Fork
- 100
- Merge trung bình
- 1 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 4
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TanStack/devtools
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 74/100
Tất cả issue của TanStack/devtools
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
dennys-bd/agent-hive#184 ·
-
Add: hunch Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
AbdelStark/awesome-typesafe#104 ·
-
ai-observability bug team/ai-observability
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
vicharanashala/fln#563 ·