Skip to content

Commit 608007a

Browse files
authored
fix(router): catch stringifyParams errors and render errorComponent (#6718)
1 parent ad0beaf commit 608007a

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

packages/router-core/src/router.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,8 +1883,16 @@ export class RouterCore<
18831883
const fn =
18841884
route.options.params?.stringify ?? route.options.stringifyParams
18851885
if (fn) {
1886-
changedParams = true
1887-
Object.assign(nextParams, fn(nextParams))
1886+
try {
1887+
Object.assign(nextParams, fn(nextParams))
1888+
changedParams = true
1889+
} catch {
1890+
// Ignore errors here. When a paired parseParams is defined,
1891+
// extractStrictParams will re-throw during route matching,
1892+
// storing the error on the match and allowing the route's
1893+
// errorComponent to render. If no parseParams is defined,
1894+
// the stringify error is silently dropped.
1895+
}
18881896
}
18891897
}
18901898
}

0 commit comments

Comments
 (0)