Skip to content

Commit c647a1d

Browse files
committed
fix(showcase/scripts): bundle-demo-content watch-mode tracks failure state
The watch loop logged '[watch] bundle failed' once and then fell silent — repeat failures looked like success, and recoveries were invisible (no news = assumed fine). Track the last error in module scope so we distinguish first-failure from repeat-failure, and log an explicit 'bundle recovered' note when the next green run clears the state. Makes dev-mode transitions visible instead of silent.
1 parent 018be75 commit c647a1d

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

showcase/scripts/bundle-demo-content.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,13 +545,34 @@ try {
545545

546546
if (process.argv.includes("--watch")) {
547547
let timer: NodeJS.Timeout | null = null;
548+
// Track the last failure so transitions are visible. The previous
549+
// implementation logged a single `[watch] bundle failed` and then fell
550+
// silent on both repeat failures (no news = assumed fine) and on
551+
// recovery (no news = actually, it's fine again). Operators reading a
552+
// dev log couldn't tell either way. Now we log on first-failure,
553+
// distinguish repeat failures, and emit an explicit "recovered" note
554+
// when the next successful run clears the state.
555+
let lastWatchError: Error | null = null;
548556
const rebundle = () => {
549557
if (timer) clearTimeout(timer);
550558
timer = setTimeout(() => {
551559
try {
552560
main();
561+
if (lastWatchError) {
562+
console.log("[watch] bundle recovered");
563+
lastWatchError = null;
564+
}
553565
} catch (e) {
554-
console.error("[watch] bundle failed:", e);
566+
const err = e as Error;
567+
if (
568+
lastWatchError &&
569+
lastWatchError.message === err.message
570+
) {
571+
console.error(`[watch] bundle still failing: ${err.message}`);
572+
} else {
573+
console.error("[watch] bundle failed:", err);
574+
}
575+
lastWatchError = err;
555576
}
556577
}, 200);
557578
};

0 commit comments

Comments
 (0)