fix(start-client-core): allow middleware to catch server function handler errors#6392
Conversation
📝 WalkthroughWalkthroughAdds a new route (/middleware/catch-handler-error) and E2E test, and changes middleware error propagation in the server-fn executor so downstream errors bubble up to allow middleware try/catch to intercept them. Changes
Sequence Diagram(s)mermaid (Note: colored rectangles are not used because the diagram focuses on sequential message flow.) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
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
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 |
e2e/react-start/server-functions/src/routes/middleware/catch-handler-error.tsx
Outdated
Show resolved
Hide resolved
c6a1a85 to
ef8e958
Compare
|
View your CI Pipeline Execution ↗ for commit ef8e958
☁️ Nx Cloud last updated this comment at |
…dler errors (TanStack#6392) fix(start-client-core): allow middleware to catch server function handler errors (TanStack#6381)
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.