Skip to content
Source
Sign inSign up
TanStack/router

fix(start): handle params.parse failures before server route handlers #8637

OpenSheraff(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromfix/server-route-params-parse-failureopened

Showing 9 changed files with 42 additions and 1 deletion (loading 5).

x
0 of 9 viewed, 9 left
5 additions and 0 deletions.changeset/server-route-params-parse-failure.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/start-server-core': patch
+---
+​
+Respond with a 404 when a server route handler or its `params.parse` throws `notFound()`, instead of a 500. When `params.parse` throws on a route with a component, requests that explicitly accept `text/html` now render the page's not-found or error state, as they did before parsed params reached server handlers.
1 addition and 0 deletionsdocs/router/api/router/RouteOptionsType.mdModified
View file
@@ -84,6 +84,7 @@
- Type: `(rawParams: Record<string, string>) => TParams | false`
- Optional
- A function that will be called when this route is matched and passed the raw params from the current location and return valid parsed params. If this function throws, the route will be put into an error state and the error will be thrown during render. If this function returns parsed params, its return value will be used as the route's params and the return type will be inferred into the rest of the router.
+- Throwing `notFound()` or `redirect()` from this function is handled like throwing them from `beforeLoad`: the route renders its not-found state or the router redirects.
- This is a planning callback. It must be deterministic and side-effect-free for the same input.
- Experimental: returning `false` during incoming route matching skips this route and allows matching to continue to another candidate route.
​
36 additions and 1 deletiondocs/start/framework/react/guide/server-routes.mdModified
View file
@@ -243,7 +243,7 @@
Each HTTP method handler receives an object with the following properties:
​