You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Router devtools crash when search params contain a BigInt (JSON.stringify in history tracking) #8768
TanStackRouterDevtoolsPanel throws TypeError: Do not know how to serialize a BigInt as soon as the current route's validated search holds a bigint, e.g. a route whose validateSearch decodes an int64 id. The router itself handles it fine (the app's custom parseSearch/stringifySearch round-trip the value). The crash comes from the devtools' history tracking, which compares locations with JSON.stringify:
JSON.stringify throws on any bigint, and the error surfaces as an uncaught route error ("The following error wasn't caught by any route!").
Steps to reproduce
Configure the router with a parseSearch/stringifySearch that supports bigints, and a route whose validateSearch returns e.g. { id: 9007199254740993n }.
Mount TanStackRouterDevtoolsPanel.
Navigate to that route: the devtools throw TypeError: Do not know how to serialize a BigInt.
Expected behavior
The devtools shouldn't assume search values are JSON-serializable. The router has already serialized the search with the app's own stringifySearch, so comparing location.searchStr (or location.href) needs no JSON.stringify and respects custom serializers. Wherever the devtools must stringify search values for display, a configurable serializer that defaults to JSON.stringify would match what was suggested for Query's devtools in TanStack/query#3082. That issue is the same class of bug, still commonly worked around by patching BigInt.prototype.toJSON.
Platform
@tanstack/router-devtools-core 1.168.2 (latest), via @tanstack/react-router-devtools
Activity