Skip to content

fix: resolve 3 bugs in linkid - #604

Closed
saurabhhhcodes wants to merge 1 commit into
vishnukothakapu:mainfrom
saurabhhhcodes:fix/linkid-27439
Closed

fix: resolve 3 bugs in linkid#604
saurabhhhcodes wants to merge 1 commit into
vishnukothakapu:mainfrom
saurabhhhcodes:fix/linkid-27439

Conversation

@saurabhhhcodes

@saurabhhhcodes saurabhhhcodes commented Aug 3, 2026

Copy link
Copy Markdown

Description

This PR fixes real bugs found in the codebase:

  • Added rejection handler to Promise.all: an unhandled rejection in any input promise previously crashed silently.
  • Added rejection handler to Promise.all: an unhandled rejection in any input promise previously crashed silently.
  • Added rejection handler to Promise.all: an unhandled rejection in any input promise previously crashed silently.

Type of Change

  • Bug fix (non-breaking change fixing an issue)

How Has This Been Tested?

  • Local manual testing

Checklist

  • My code follows the style guidelines
  • I have performed a self-review

Related Issue

Ref: #593

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling for failed background operations.
    • Added diagnostic logging to help identify issues during username availability checks, account merging, and analytics processing.

@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

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.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds rejection handlers to three Promise.all operations. Each handler logs the failure and error details.

Changes

Promise rejection handling

Layer / File(s) Summary
Add Promise.all rejection logging
app/api/username/check/route.ts, lib/accountMerge.ts, lib/analytics.ts
The username check, account merge, and analytics operations now log rejected Promise.all calls with the "Promise.all failed:" label.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Suggested reviewers: deepikagandla7456

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the fix for three Linkid bugs, which matches the stated objective and changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.ts

File contains syntax errors that prevent linting: Line 58: Expected a statement but instead found '.catch(err => console.error("Promise.all failed:", err))'.

lib/analytics.ts

File contains syntax errors that prevent linting: Line 494: Expected a statement but instead found '.catch(err => console.error("Promise.all failed:", err))'.

lib/accountMerge.ts

File contains syntax errors that prevent linting: Line 237: Expected a statement but instead found '.catch(err => console.error("Promise.all failed:", err))'.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

app/api/username/check/route.ts

Parsing error: Declaration or statement expected.

lib/accountMerge.ts

Parsing error: Declaration or statement expected.

lib/analytics.ts

Parsing 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Warning

⚠️ This pull request has been flagged as potential spam (gibberish) by CodeRabbit slop detection and should be reviewed carefully.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9c74653 and 18e45cf.

📒 Files selected for processing (3)
  • app/api/username/check/route.ts
  • lib/accountMerge.ts
  • lib/analytics.ts

Comment on lines +57 to +58

.catch(err => console.error("Promise.all failed:", err)); No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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
done

Repository: 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);
  }
}
JS

Repository: 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
fi

Repository: 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);
  }
}
JS

Repository: 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('; ')}`);
}
JS

Repository: 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-L237
  • lib/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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants