Skip to content

Commit 6a6ddb5

Browse files
🧹 Remove console logs in production helper (#27)
🎯 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: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com>
1 parent ec9e7ab commit 6a6ddb5

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

‎src/utils/helper.ts‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,22 @@ export function promiseAny<T>(promises: Promise<T>[]) {
2626
}
2727

2828
export const ping = async (url: string) => {
29-
let pingFinished = false;
3029
return Promise.race([
3130
fetch(url, {
3231
method: 'HEAD',
3332
})
34-
.then(({ status, statusText }) => {
35-
pingFinished = true;
33+
.then(({ status }) => {
3634
if (status === 200) {
37-
console.log('ping success', url);
3835
return url;
3936
}
40-
console.log('ping failed', url, status, statusText);
4137
throw Error('ping failed');
4238
})
43-
.catch((e) => {
44-
pingFinished = true;
45-
console.log('ping error', url, e);
39+
.catch(() => {
4640
throw Error('ping error');
4741
}),
4842
new Promise((_, reject) =>
4943
setTimeout(() => {
5044
reject(Error('ping timeout'));
51-
if (!pingFinished) {
52-
console.log('ping timeout', url);
53-
}
5445
}, 2000),
5546
),
5647
]) as Promise<string | null>;
@@ -64,7 +55,6 @@ export const testUrls = async (urls?: string[]) => {
6455
if (ret) {
6556
return ret;
6657
}
67-
console.log('all ping failed, use first url:', urls[0]);
6858
return urls[0];
6959
};
7060

0 commit comments

Comments
 (0)