Skip to content

[P3] Eliminate silently swallowed errors via .catch(() => {}) #681

Description

@itsmiso-ai

Problem: Multiple places in the codebase use .catch(() => {}) to silently discard errors. This hides failures during cleanup operations, JSON parsing, and release-lock calls, making debugging harder when things go wrong. While some of these are deliberate best-effort cleanup (releaseLock after a failure), even those should at minimum log a warning so operators can trace issues.

Evidence:

$ grep -rn "\.catch(() => {})" ./src --include="*.ts" --include="*.tsx" | grep -v node_modules

src/components/issue-card.tsx:159:  const data = await res.json().catch(() => ({}));
src/components/issue-card.tsx:213:  const data = await res.json().catch(() => ({}));
src/components/issue-card.tsx:266:  const data = await res.json().catch(() => ({}));
src/app/login/page.tsx:31:           .catch(() => {});
src/app/automation/page.tsx:200:     .catch(() => {});
src/app/api/automation/sync/route.ts:27:  const body = await request.json().catch(() => ({}));
src/app/api/automation/sync/route.ts:63:    await releaseLock(runId).catch(() => {});
src/app/api/sync/route.ts:73:       await releaseLock(runId).catch(() => {});
src/app/api/sync/scheduled/route.ts:188:  }).catch(() => {});
src/app/api/sync/scheduled/route.ts:190:  await releaseLock(runId).catch(() => {});

The production-critical silent swallows:

  • releaseLock() catch in sync routes — if a lock release fails silently, subsequent sync runs may fail with lock-contention errors and the operator will not know why
  • request.json().catch(() => ({})) — malformed JSON bodies silently become empty objects, potentially masking API misuse

Acceptance:

  • Each .catch(() => {}) is replaced with appropriate error handling
  • Best-effort cleanup (e.g., releaseLock after failure) uses .catch((e) => console.warn("Failed to release lock:", e))
  • JSON parsing falls back to a sensible default but logs a warning: .catch((e) => { console.warn("Failed to parse JSON body:", e); return {}; })
  • Client-side .catch(() => {}) in components at least logs: .catch((e) => console.error("Action failed:", e))
  • All existing tests continue to pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    auditAudit, review, or investigation work.priority/p3Low priority.status/readyReady for Dispatch worker pickup.type/choreRoutine tasks and maintenance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions