Skip to content

Commit 4e3cd95

Browse files
Treat preview stderr deprecations and npm warns as warnings (#3473)
## Summary - Downgrade non-actionable stderr lines (`DeprecationWarning`, `Deprecation:`, `npm warn`) from errors to warnings in the preview loading screen - Exclude those messages from the startup error banner count - Add `isWarningMessage` helper with unit tests ## Test plan - [x] `npm test -- src/components/preview_panel/PreviewLoadingScreen.test.ts` - [ ] Start an app with deprecation/npm warn output on stderr and confirm they show as warnings, not in the error banner 🤖 Generated with [Claude Code](https://claude.com/claude-code) Made with [Cursor](https://cursor.com) Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 302e590 commit 4e3cd95

2 files changed

Lines changed: 32 additions & 8 deletions

File tree

src/components/preview_panel/PreviewLoadingScreen.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
22
import type { ConsoleEntry } from "@/ipc/types";
33
import {
44
getPreviewLoadingSessionStartedAt,
5+
isWarningMessage,
56
sanitizePreviewErrorForPrompt,
67
} from "./PreviewLoadingScreen";
78

@@ -55,6 +56,26 @@ describe("PreviewLoadingScreen helpers", () => {
5556
).toBe(200);
5657
});
5758

59+
describe("isWarningMessage", () => {
60+
it.each([
61+
"(node:1234) [DEP0123] DeprecationWarning: Buffer() is deprecated",
62+
"Deprecation: The `punycode` module is deprecated.",
63+
"npm warn deprecated inflight@1.0.6",
64+
"NPM WARN deprecated glob@7.2.3",
65+
])("returns true for non-actionable stderr: %s", (message) => {
66+
expect(isWarningMessage(message)).toBe(true);
67+
});
68+
69+
it.each([
70+
"Error: Cannot find module 'react'",
71+
"ELIFECYCLE Command failed with exit code 1",
72+
"Failed to compile",
73+
"Deprecation without colon suffix",
74+
])("returns false for actionable errors: %s", (message) => {
75+
expect(isWarningMessage(message)).toBe(false);
76+
});
77+
});
78+
5879
it("removes control characters and caps error excerpts sent to AI", () => {
5980
const message = `\u001b[31merror\u001b[0m\u0000${"x".repeat(2_100)}`;
6081
const sanitized = sanitizePreviewErrorForPrompt(message);

src/components/preview_panel/PreviewLoadingScreen.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,19 @@ function formatTime(ts: number) {
3131
return d.toTimeString().slice(0, 8);
3232
}
3333

34-
// Node prints DeprecationWarnings to stderr (e.g. "(node:1234) [DEP0123]
35-
// DeprecationWarning: ..."), so they surface here as level="error" even
36-
// though they aren't actionable failures. Treat them as warnings: don't
37-
// count them in the error banner, and render them with warn styling.
38-
function isDeprecationWarning(message: string): boolean {
39-
return /DeprecationWarning/i.test(message);
34+
// Node/npm print deprecations and warnings to stderr, so they surface here as
35+
// level="error" even though they aren't actionable failures. Treat them as
36+
// warnings: don't count them in the error banner, and render with warn styling.
37+
export function isWarningMessage(message: string): boolean {
38+
return (
39+
/DeprecationWarning/i.test(message) ||
40+
/Deprecation:\s/i.test(message) ||
41+
/npm warn/i.test(message)
42+
);
4043
}
4144

4245
function displayLevel(entry: ConsoleEntry): ConsoleEntry["level"] {
43-
if (entry.level === "error" && isDeprecationWarning(entry.message)) {
46+
if (entry.level === "error" && isWarningMessage(entry.message)) {
4447
return "warn";
4548
}
4649
return entry.level;
@@ -170,7 +173,7 @@ export function PreviewLoadingScreen({
170173
const seen = new Set<string>();
171174
const result: string[] = [];
172175
for (const entry of sessionEntries) {
173-
if (entry.level !== "error" || isDeprecationWarning(entry.message)) {
176+
if (entry.level !== "error" || isWarningMessage(entry.message)) {
174177
continue;
175178
}
176179
const key = entry.message;

0 commit comments

Comments
 (0)