-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(start-client-core): allow middleware to catch server function handler errors #6392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThis PR fixes a bug where middleware could not catch errors thrown by server functions. It modifies error propagation in the middleware execution layer to allow try/catch blocks in middleware to properly intercept downstream errors, adds a new test route demonstrating the fixed behavior, and includes an end-to-end test verifying the middleware error handling. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🧰 Additional context used📓 Path-based instructions (2)**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{js,ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (5)📚 Learning: 2025-09-28T21:41:45.233ZApplied to files:
📚 Learning: 2025-12-06T15:03:07.223ZApplied to files:
📚 Learning: 2025-12-17T02:17:55.086ZApplied to files:
📚 Learning: 2025-10-01T18:31:35.420ZApplied to files:
📚 Learning: 2025-10-08T08:11:47.088ZApplied to files:
🧬 Code graph analysis (2)e2e/react-start/server-functions/src/routes/middleware/catch-handler-error.tsx (1)
e2e/react-start/server-functions/tests/server-functions.spec.ts (1)
🔇 Additional comments (6)
✏️ Tip: You can disable this entire section by setting 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 & Purpose
Fixes #6381 - Middleware can now properly catch errors thrown by server function handlers.
Changes
packages/start-client-core/src/createServerFn.ts: ModifiedexecuteMiddlewareto throw errors fromresult.errorinstead of silently returning them in context, allowing parent middleware to catch them with try/catche2e/react-start/server-functions/src/routes/middleware/catch-handler-error.tsx: Added test route demonstrating middleware error catchinge2e/react-start/server-functions/tests/server-functions.spec.ts: Added e2e test verifying middleware can catch handler errorsSummary by CodeRabbit
New Features
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.