From ca4f6894a70bbe2a592fd9a820d538a7641f64b5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Feb 2026 14:59:03 +0000 Subject: [PATCH] Track hadReadError flag to log routes after JSON parse error recovery Co-authored-by: typicode <5502029+typicode@users.noreply.github.com> --- src/bin.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bin.ts b/src/bin.ts index bebe4e0..17d4cdd 100644 --- a/src/bin.ts +++ b/src/bin.ts @@ -183,6 +183,7 @@ app.listen(port, () => { // Watch file for changes if (process.env["NODE_ENV"] !== "production") { let writing = false; // true if the file is being written to by the app + let hadReadError = false; let prevEndpoints = ""; observer.onWriteStart = () => { @@ -200,16 +201,18 @@ if (process.env["NODE_ENV"] !== "production") { } const nextEndpoints = JSON.stringify(Object.keys(data).sort()); - if (prevEndpoints !== nextEndpoints) { + if (hadReadError || prevEndpoints !== nextEndpoints) { console.log(); logRoutes(data); } + hadReadError = false; }; watch(file).on("change", () => { // Do no reload if the file is being written to by the app if (!writing) { db.read().catch((e) => { if (e instanceof SyntaxError) { + hadReadError = true; return console.log(chalk.red(["", `Error parsing ${file}`, e.message].join("\n"))); } console.log(e);