fix: guard all res.json() calls and non-blocking campaign bootstrap#333
fix: guard all res.json() calls and non-blocking campaign bootstrap#333
Conversation
Prevents logging raw error objects to browser console, consistent with server-side error logging conventions. https://claude.ai/code/session_01Ukm6sf45r8mT5fnw8bgYn7
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughModified error logging in the token-fetch catch block to normalize the error output. Changed from logging the raw error object to extracting and logging only the message for Error instances or converting other values to strings, while preserving existing UI error handling behavior. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Summary
Hardens every client-side
res.json()call with a.catch()guard to prevent unhandledSyntaxErrorwhen the server returns non-JSON responses (e.g., reverse proxy 502 HTML pages). Also relocates the welcome campaign bootstrap fromserver/routes.tstoserver/index.tsas a non-blocking fire-and-forget with a 5-second timeout, preventing cold-start delays.Changes
Client-side JSON resilience
.catch()guard togetQueryFninclient/src/lib/queryClient.ts— covers all hooks using the default query function.catch()guards to all customqueryFnimplementations across hooks:use-monitors.ts,use-tags.ts,use-auth.ts,use-conditions.ts,use-notification-channels.ts,use-notification-preferences.ts,use-slack.ts,use-api-keys.ts,use-campaigns.ts.catch()guards to page-level fetch calls:AdminErrors.tsx,ExtensionAuth.tsx,Support.tsx,DashboardNav.tsx,UpgradeDialog.tsxisErroranderrorfromuseAuthhook for future error-state UIconsole.errorinExtensionAuth.tsxto logerr.messageinstead of raw error objectServer-side startup optimization
server/routes.tstoserver/index.tsPromise.racetimeout with structured error handlingregisterRoutes()now returns{ httpServer, campaignConfigsReady }to communicate readinessTest infrastructure
happy-domtojsdomfor CI compatibilitymswin vitest config to fix module resolutionhappy-domdependencyHow to test
npm run check— TypeScript compiles cleanlynpm run test— All 84 test files pass (2081 tests)npm run build— Production build succeedshttps://claude.ai/code/session_01Ukm6sf45r8mT5fnw8bgYn7
Summary by CodeRabbit