fix: resolve 3 bugs in linkid - #604
Conversation
|
Someone is attempting to deploy a commit to the vishnukothakapu's projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughThe change adds rejection handlers to three ChangesPromise rejection handling
Estimated code review effort: 1 (Trivial) | ~3 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Biome (2.5.5)app/api/username/check/route.tsFile contains syntax errors that prevent linting: Line 58: Expected a statement but instead found '.catch(err => console.error("Promise.all failed:", err))'. lib/analytics.tsFile contains syntax errors that prevent linting: Line 494: Expected a statement but instead found '.catch(err => console.error("Promise.all failed:", err))'. lib/accountMerge.tsFile contains syntax errors that prevent linting: Line 237: Expected a statement but instead found '.catch(err => console.error("Promise.all failed:", err))'. 🔧 ESLint
app/api/username/check/route.tsParsing error: Declaration or statement expected. lib/accountMerge.tsParsing error: Declaration or statement expected. lib/analytics.tsParsing error: Declaration or statement expected. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Warning |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/api/username/check/route.ts`:
- Around line 57-58: Attach the catch handlers directly to their corresponding
Promise.all expressions and rethrow after logging so failures propagate to the
API route. Apply this in app/api/username/check/route.ts lines 57-58,
lib/accountMerge.ts lines 236-237, and lib/analytics.ts lines 493-494; each site
requires the same direct chaining fix.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 9f8edcd5-3486-4c87-8227-0a1bf4fc880c
📒 Files selected for processing (3)
app/api/username/check/route.tslib/accountMerge.tslib/analytics.ts
|
|
||
| .catch(err => console.error("Promise.all failed:", err)); No newline at end of file |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
files=(
"app/api/username/check/route.ts"
"lib/accountMerge.ts"
"lib/analytics.ts"
)
for file in "${files[@]}"; do
if rg -nP '^\s*\.catch\s*\(' "$file"; then
echo "Standalone catch found in $file" >&2
exit 1
fi
doneRepository: vishnukothakapu/linkid
Length of output: 279
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
files=(
"app/api/username/check/route.ts"
"lib/accountMerge.ts"
"lib/analytics.ts"
)
printf 'Files and .catch locations:\n'
for file in "${files[@]}"; do
echo "--- $file ---"
if [ -f "$file" ]; then
nl -ba "$file" | sed -n '1,90p;220,245p;470,505p'
echo "Standalone catches:"
rg -n '(Promise\.all|\.catch\s*\()' "$file" || true
else
echo "missing"
fi
done
printf '\nStructural parser-style availability check:\n'
node - <<'JS'
const fs = require('fs');
const files = [
"app/api/username/check/route.ts",
"lib/accountMerge.ts",
"lib/analytics.ts"
];
for (const file of files) {
if (!fs.existsSync(file)) continue;
const text = fs.readFileSync(file, 'utf8');
const { parseModuleSync } = require('`@typescript-eslint/typescript-estree`');
try {
parseModuleSync(text, { filePath: file });
console.log(`${file}: parsed OK`);
} catch (e) {
console.log(`${file}: parse error:`, (e && e.message) || String(e));
console.log(' lines:', e && e.lineNumber);
}
}
JSRepository: vishnukothakapu/linkid
Length of output: 269
🏁 Script executed:
#!/usr/bin/env bash
set -euo Pipefail
echo "Check whether a standalone catch after function/const can be syntactically attached in current checkout TS configs/tools"
if command -v pnpm >/dev/null 2>&1 && [ -f package.json ]; then
cat package.json | jq '.packageManager, .dependencies.typescript, .devDependencies.typescript, .devDependencies["`@biomejs/biome`"]' || true
fiRepository: vishnukothakapu/linkid
Length of output: 209
🏁 Script executed:
#!/bin/bash
set -euo pipefail
files=(
"app/api/username/check/route.ts"
"lib/accountMerge.ts"
"lib/analytics.ts"
)
printf 'Files and relevant contents:\n'
for file in "${files[@]}"; do
echo "--- $file ---"
if [ -f "$file" ]; then
wc -l "$file"
sed -n '1,90p' "$file"
sed -n '220,245p' "$file"
sed -n '470,505p' "$file"
echo "Promise/catch occurrences:"
grep -nE 'Promise\.all|\.catch\s*\(' "$file" || true
else
echo "missing"
fi
echo
done
printf '\nTypeScript parser availability check:\n'
node - <<'JS'
const fs = require('fs');
const files = [
"app/api/username/check/route.ts",
"lib/accountMerge.ts",
"lib/analytics.ts"
];
for (const file of files) {
if (!fs.existsSync(file)) {
console.log(`${file}: missing`);
continue;
}
const text = fs.readFileSync(file, 'utf8');
let parseModuleSync;
try {
parseModuleSync = require('`@typescript-eslint/typescript-estree`').parseModuleSync;
} catch (e) {
console.log(`${file}: unavailable parser dependency`);
continue;
}
try {
parseModuleSync(text, { filePath: file });
console.log(`${file}: parsed OK`);
} catch (e) {
console.log(`${file}: parse error:`, (e && e.message) || String(e));
console.log(` line:`, e && e.lineNumber);
}
}
JSRepository: vishnukothakapu/linkid
Length of output: 9747
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf 'TypeScript compiler availability check:\n'
node - <<'JS'
const fs = require('fs');
const files = [
"app/api/username/check/route.ts",
"lib/accountMerge.ts",
"lib/analytics.ts"
];
let ts;
try {
ts = require('typescript');
} catch (e) {
console.log('typescript compiler unavailable');
process.exit(0);
}
const host = ts.createCompilerHost({ target: ts.ScriptTarget.ES2020, module: ts.ModuleKind.CommonJS });
const originalReadFile = host.readFile;
host.readFile = (fileName) => {
if (fs.existsSync(fileName)) return fs.readFileSync(fileName, 'utf8');
return originalReadFile(fileName);
};
for (const file of files) {
if (!fs.existsSync(file)) {
console.log(`${file}: missing`);
continue;
}
const sourceFile = ts.createSourceFile(file, fs.readFileSync(file, 'utf8'), ts.ScriptTarget.ES2020, true);
const diagnostics = ts.createProgram({ rootNames: [file], options: {}, host }, ts.getBindAndCheckDiagnostics).getSyntacticDiagnostics(sourceFile)
.map(d => ({ line: d.file ? d.file.getLineAndCharacterOfPosition(d.start).line + 1 : undefined, message: ts.flattenDiagnosticMessageText(d.messageText, '\n') }));
console.log(`${file}: ${diagnostics.length === 0 ? 'parsed OK' : 'parse errors (' + diagnostics.length + ')'} ${diagnostics.map(d => (d.line || '?') + ':' + d.message).join('; ')}`);
}
JSRepository: vishnukothakapu/linkid
Length of output: 613
Attach each catch handler to the corresponding Promise.all expression.
These .catch expressions are outside any function body, which makes app/api/username/check/route.ts, lib/accountMerge.ts, and lib/analytics.ts fail to parse. Bind each handler directly to the Promise.all call and rethrow after logging so failure still propagates to the API route.
Proposed fix pattern
-const [a, b] = await Promise.all([...]);
+const [a, b] = await Promise.all([...]).catch((err) => {
+ console.error("Promise.all failed:", err);
+ throw err;
+});🧰 Tools
🪛 Biome (2.5.5)
[error] 58-58: Expected a statement but instead found '.catch(err => console.error("Promise.all failed:", err))'.
(parse)
📍 Affects 3 files
app/api/username/check/route.ts#L57-L58(this comment)lib/accountMerge.ts#L236-L237lib/analytics.ts#L493-L494
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@app/api/username/check/route.ts` around lines 57 - 58, Attach the catch
handlers directly to their corresponding Promise.all expressions and rethrow
after logging so failures propagate to the API route. Apply this in
app/api/username/check/route.ts lines 57-58, lib/accountMerge.ts lines 236-237,
and lib/analytics.ts lines 493-494; each site requires the same direct chaining
fix.
Source: Linters/SAST tools
Description
This PR fixes real bugs found in the codebase:
Promise.all: an unhandled rejection in any input promise previously crashed silently.Promise.all: an unhandled rejection in any input promise previously crashed silently.Promise.all: an unhandled rejection in any input promise previously crashed silently.Type of Change
How Has This Been Tested?
Checklist
Related Issue
Ref: #593
Summary by CodeRabbit