From 1f7f39db11e6e24df9c69df591d6ccd2781f4210 Mon Sep 17 00:00:00 2001 From: Abhisar Mehta Date: Sat, 21 Feb 2026 13:12:23 +0530 Subject: [PATCH 1/2] fix(router): catch stringifyParams errors and render errorComponent Wrap the stringifyParams call in buildLocation with a try/catch so that errors thrown by params.stringify (or the deprecated stringifyParams) no longer crash the application. Previously these errors would: 1. Bypass the route's errorComponent and render the defaultErrorComponent instead, because the error propagated outside the route's error boundary. 2. Cause a blank page on reload, because the uncaught error crashed the Transitioner's React.useEffect during URL canonicalization. By catching the error in buildLocation and skipping the stringification, the router continues with the original params. The error is then properly caught during route matching in extractStrictParams/parseParams, which stores it on the match object and lets the route's errorComponent render. This follows the same pattern already used for validateSearch errors in buildLocation (caught and ignored because they are handled in matchRoutes). Fixes #1834 --- packages/router-core/src/router.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/router-core/src/router.ts b/packages/router-core/src/router.ts index 23e9f99d0c6..2e3a2cce3b4 100644 --- a/packages/router-core/src/router.ts +++ b/packages/router-core/src/router.ts @@ -1883,8 +1883,15 @@ export class RouterCore< const fn = route.options.params?.stringify ?? route.options.stringifyParams if (fn) { - changedParams = true - Object.assign(nextParams, fn(nextParams)) + try { + Object.assign(nextParams, fn(nextParams)) + changedParams = true + } catch { + // ignore errors here because they will be properly handled + // during route matching via parseParams/extractStrictParams, + // which stores the error on the match and renders the + // route's errorComponent + } } } } From d178f80665ff381043105f52a8976e15348e69c3 Mon Sep 17 00:00:00 2001 From: Abhisar Mehta Date: Sat, 21 Feb 2026 14:31:01 +0530 Subject: [PATCH 2/2] refactor: clarify catch comment for unpaired stringifyParams case --- packages/router-core/src/router.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/router-core/src/router.ts b/packages/router-core/src/router.ts index 2e3a2cce3b4..caee16c12e3 100644 --- a/packages/router-core/src/router.ts +++ b/packages/router-core/src/router.ts @@ -1887,10 +1887,11 @@ export class RouterCore< Object.assign(nextParams, fn(nextParams)) changedParams = true } catch { - // ignore errors here because they will be properly handled - // during route matching via parseParams/extractStrictParams, - // which stores the error on the match and renders the - // route's errorComponent + // Ignore errors here. When a paired parseParams is defined, + // extractStrictParams will re-throw during route matching, + // storing the error on the match and allowing the route's + // errorComponent to render. If no parseParams is defined, + // the stringify error is silently dropped. } } }