⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
fix(review): qodo/coderabbit suggestions
justin965603628284
diff --git a/apps/api/src/scheduler/due-date-reminders.ts b/apps/api/src/scheduler/due-date-reminders.tsindex fb8d80d18..677f4269d 100644--- a/apps/api/src/scheduler/due-date-reminders.ts+++ b/apps/api/src/scheduler/due-date-reminders.ts@@ -134,9 +134,10 @@ async function processReminder(});}-export async function checkDueDateReminders(): Promise<void> {+export async function checkDueDateReminders(): Promise<{ degraded: boolean }> {const now = new Date();const windows = buildWindows(now);+ let degraded = false;for (const window of Object.values(windows)) {try {@@ -150,6 +151,7 @@ export async function checkDueDateReminders(): Promise<void> {try {await processReminder(task, window.type, window.notificationType);} catch (error) {+ degraded = true;console.error("Failed to process due date reminder", {taskId: task.id,reminderType: window.type,@@ -158,10 +160,13 @@ export async function checkDueDateReminders(): Promise<void> {}}} catch (error) {+ degraded = true;console.error("Failed to query tasks for due date reminders", {reminderType: window.type,error,});}}++ return { degraded };}diff --git a/apps/api/src/scheduler/index.ts b/apps/api/src/scheduler/index.tsindex 4150a0e3b..7e671422f 100644--- a/apps/api/src/scheduler/index.ts+++ b/apps/api/src/scheduler/index.ts@@ -7,27 +7,39 @@ import { checkTrialReminders } from "./trial-reminders";const jobs: Cron[] = [];+type JobOutcome = { degraded?: boolean };++// Cron jobs swallow their operational failures (per-item try/catch) so they+// can keep processing the rest of the batch. Reporting Sentry status purely+// from the thrown-rejection channel would always show "ok" for any partially+// failed run. Inspect the returned outcome instead so handled failures light+// up the monitor without aborting the rest of the work. Unexpected throws are+// captured as exception events and swallowed so one bad tick can't take down+// the scheduler via an unhandled rejection.function withCheckIn<T>(name: string, fn: () => Promise<T>) {- return async () => {+ return async (): Promise<void> => {const checkInId = Sentry.captureCheckIn({monitorSlug: name,status: "in_progress",});try {const result = await fn();+ const degraded = Boolean(+ (result as JobOutcome | null | undefined)?.degraded,+ );Sentry.captureCheckIn({checkInId,monitorSlug: name,- status: "ok",+ status: degraded ? "error" : "ok",});- return result;} catch (error) {+ Sentry.captureException(error, { tags: { area: "cron", job: name } });Sentry.captureCheckIn({checkInId,monitorSlug: name,status: "error",});- throw error;+ console.error(`Cron job ${name} failed`, error);}};}diff --git a/apps/api/src/scheduler/project-webhook-reminders.ts b/apps/api/src/scheduler/project-webhook-reminders.tsindex 31ffb6f65..3a82e3d60 100644--- a/apps/api/src/scheduler/project-webhook-reminders.ts+++ b/apps/api/src/scheduler/project-webhook-reminders.ts@@ -15,7 +15,9 @@ import { REMINDER_WINDOW_MINUTES } from "./reminder-timing";const MINUTE_MS = 60 * 1000;-export async function checkProjectWebhookReminders(): Promise<void> {+export async function checkProjectWebhookReminders(): Promise<{+ degraded: boolean;+}> {const now = new Date();const integrations = await db.select({@@ -30,6 +32,7 @@ export async function checkProjectWebhookReminders(): Promise<void> {eq(integrationTable.isActive, true),),);+ let degraded = false;for (const integration of integrations) {try {@@ -95,6 +98,7 @@ export async function checkProjectWebhookReminders(): Promise<void> {}}} catch (error) {+ degraded = true;console.error("Failed to process project webhook reminder", {integrationId: integration.id,projectId: integration.projectId,@@ -102,4 +106,6 @@ export async function checkProjectWebhookReminders(): Promise<void> {});}}++ return { degraded };}diff --git a/apps/api/src/scheduler/seat-reconciliation.ts b/apps/api/src/scheduler/seat-reconciliation.tsindex 2f087e306..c574a1064 100644--- a/apps/api/src/scheduler/seat-reconciliation.ts+++ b/apps/api/src/scheduler/seat-reconciliation.ts@@ -29,9 +29,11 @@ async function findDriftedWorkspaces() {.limit(BATCH_SIZE);}-export async function reconcileWorkspaceSeats(): Promise<void> {+export async function reconcileWorkspaceSeats(): Promise<{+ degraded: boolean;+}> {if (!isBillingEnabled()) {- return;+ return { degraded: false };}let drifted: Awaited<ReturnType<typeof findDriftedWorkspaces>>;@@ -39,19 +41,21 @@ export async function reconcileWorkspaceSeats(): Promise<void> {drifted = await findDriftedWorkspaces();} catch (error) {console.error("billing: seat reconciliation query failed", error);- return;+ return { degraded: true };}if (drifted.length === 0) {- return;+ return { degraded: false };}let repaired = 0;+ let degraded = false;for (const { workspaceId } of drifted) {try {await syncWorkspaceSeats(workspaceId);repaired += 1;} catch (error) {+ degraded = true;console.error(`billing: seat reconciliation failed for workspace ${workspaceId}`,error,@@ -62,4 +66,5 @@ export async function reconcileWorkspaceSeats(): Promise<void> {console.log(`billing: seat reconciliation resynced ${repaired}/${drifted.length} workspaces`,);+ return { degraded };}diff --git a/apps/web/src/query-client/index.ts b/apps/web/src/query-client/index.tsindex 208ad5ccd..6793016c5 100644--- a/apps/web/src/query-client/index.ts+++ b/apps/web/src/query-client/index.ts@@ -1,20 +1,51 @@import * as Sentry from "@sentry/react";import { MutationCache, QueryCache, QueryClient } from "@tanstack/react-query";-function captureCacheError(error: unknown, context: "query" | "mutation") {- if (!(error instanceof Error)) return;- // These are the noisy network-layer errors TanStack raises before any- // fetcher-level error message exists; we still want them captured, but- // without drowning the queue in offline-tab reloads.- if (+// TanStack raises these before any fetcher-level message exists; CORS rejections+// from the browser also surface here. Used both to skip auto-retry and to tag+// the captured event so offline-tab reloads don't drown the queue.+function isNetworkError(error: unknown): boolean {+ if (!(error instanceof Error)) return false;+ return (error.message.includes("Failed to fetch") ||error.message.includes("NetworkError") ||- error.message.includes("Load failed")- ) {- Sentry.captureException(error, { tags: { area: `network.${context}` } });- return;+ error.message.includes("Load failed") ||+ error.message.includes("CORS")+ );+}++// Cancellation surfaces as AbortError from the fetch signal and from TanStack's+// own query cancellation. Treat both as expected control flow, not a failure.+function isCancellationError(error: Error): boolean {+ return (+ error.name === "AbortError" ||+ error.message.toLowerCase().includes("aborted")+ );+}++// In-module cooldown so an offline tab doesn't fire one Sentry event per cache+// entry on every retry tick. Network-class only; API errors are not rate-limited.+const NETWORK_REPORT_COOLDOWN_MS = 60_000;+const networkErrorCooldowns = new Map<string, number>();++function captureCacheError(error: unknown, context: "query" | "mutation") {+ if (!(error instanceof Error)) return;+ if (isCancellationError(error)) return;++ const isNetwork = isNetworkError(error);+ const area = `${isNetwork ? "network" : "api"}.${context}`;++ if (isNetwork) {+ const dedupeKey = `${context}:${error.message}`;+ const lastSent = networkErrorCooldowns.get(dedupeKey);+ const now = Date.now();+ if (lastSent !== undefined && now - lastSent < NETWORK_REPORT_COOLDOWN_MS) {+ return;+ }+ networkErrorCooldowns.set(dedupeKey, now);}- Sentry.captureException(error, { tags: { area: `api.${context}` } });++ Sentry.captureException(error, { tags: { area } });}const queryClient = new QueryClient({@@ -28,18 +59,8 @@ const queryClient = new QueryClient({queries: {refetchOnWindowFocus: false,refetchOnMount: false,- retry: (failureCount, error) => {- if (error instanceof Error) {- if (- error.message.includes("Failed to fetch") ||- error.message.includes("NetworkError") ||- error.message.includes("CORS")- ) {- return false;- }- }- return failureCount < 2;- },+ retry: (failureCount, error) =>+ isNetworkError(error) ? false : failureCount < 2,},mutations: {retry: false,