From e9d0fd2120f940f0074fa9b178093f6ebd713b61 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 14 Apr 2026 01:44:33 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20Remove=20console=20logs=20in=20p?= =?UTF-8?q?roduction=20helper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🎯 What: Removed console.log statements from ping and testUrls functions in src/utils/helper.ts, as well as an unused pingFinished boolean and some unused parameter variables (statusText and e). 💡 Why: console.log statements in production code add noise to logs and can leak information. Removing these logs improves code maintainability and addresses code health issues. ✅ Verification: Verified with bun test ensuring functionality remains intact. Code formatted with Biome and compiled with TypeScript. ✨ Result: A cleaner helper.ts file without unnecessary debug logging in production. Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com> --- src/pages/realtime-metrics.tsx | 4 +++- src/utils/helper.ts | 14 ++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/pages/realtime-metrics.tsx b/src/pages/realtime-metrics.tsx index 8899d22..dd3ba19 100644 --- a/src/pages/realtime-metrics.tsx +++ b/src/pages/realtime-metrics.tsx @@ -86,7 +86,9 @@ const attributeOptions = [ ]; export const Component = () => { - const [searchParams, setSearchParams] = useSearchParams({ attribute: 'hash' }); + const [searchParams, setSearchParams] = useSearchParams({ + attribute: 'hash', + }); const [dateRange, setDateRange] = useState<[Dayjs, Dayjs]>([ dayjs().subtract(24, 'hour'), dayjs(), diff --git a/src/utils/helper.ts b/src/utils/helper.ts index c1cbf53..a5bba3f 100644 --- a/src/utils/helper.ts +++ b/src/utils/helper.ts @@ -26,31 +26,22 @@ export function promiseAny(promises: Promise[]) { } export const ping = async (url: string) => { - let pingFinished = false; return Promise.race([ fetch(url, { method: 'HEAD', }) - .then(({ status, statusText }) => { - pingFinished = true; + .then(({ status }) => { if (status === 200) { - console.log('ping success', url); return url; } - console.log('ping failed', url, status, statusText); throw Error('ping failed'); }) - .catch((e) => { - pingFinished = true; - console.log('ping error', url, e); + .catch(() => { throw Error('ping error'); }), new Promise((_, reject) => setTimeout(() => { reject(Error('ping timeout')); - if (!pingFinished) { - console.log('ping timeout', url); - } }, 2000), ), ]) as Promise; @@ -64,7 +55,6 @@ export const testUrls = async (urls?: string[]) => { if (ret) { return ret; } - console.log('all ping failed, use first url:', urls[0]); return urls[0]; };