-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(router-core): Prevents the app from crashing when a primitive value is thrown in beforeLoad #4724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(router-core): Prevents the app from crashing when a primitive value is thrown in beforeLoad #4724
Conversation
Signed-off-by: leesb971204 <[email protected]>
Signed-off-by: leesb971204 <[email protected]>
View your CI Pipeline Execution ↗ for commit b63d947
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/arktype-adapter
@tanstack/directive-functions-plugin
@tanstack/eslint-plugin-router
@tanstack/history
@tanstack/react-router
@tanstack/react-router-devtools
@tanstack/react-router-with-query
@tanstack/react-start
@tanstack/react-start-client
@tanstack/react-start-plugin
@tanstack/react-start-server
@tanstack/router-cli
@tanstack/router-core
@tanstack/router-devtools
@tanstack/router-devtools-core
@tanstack/router-generator
@tanstack/router-plugin
@tanstack/router-utils
@tanstack/router-vite-plugin
@tanstack/server-functions-plugin
@tanstack/solid-router
@tanstack/solid-router-devtools
@tanstack/solid-start
@tanstack/solid-start-client
@tanstack/solid-start-plugin
@tanstack/solid-start-server
@tanstack/start-client-core
@tanstack/start-plugin-core
@tanstack/start-server-core
@tanstack/start-server-functions-client
@tanstack/start-server-functions-fetcher
@tanstack/start-server-functions-server
@tanstack/start-storage-context
@tanstack/valibot-adapter
@tanstack/virtual-file-routes
@tanstack/zod-adapter
commit: |
Signed-off-by: leesb971204 <[email protected]>
@@ -2187,12 +2189,11 @@ export class RouterCore< | |||
throw err | |||
} | |||
|
|||
err.routerCode = routerCode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The app crashes at this point when err
is a primitive type.
route.options.onError?.(err) | ||
route.options.onError?.(err, routerCode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applies minimal changes to preserve compatibility for users accessing err.routerCode
in onError
.
In fact, there are quite a few people who use it this way.
this._handleNotFound(matches, err, { | ||
this._handleNotFound(matches, err, routerCode, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passes routerCode
separately alongside err
.
…e type error Signed-off-by: leesb971204 <[email protected]>
…ode parameter Signed-off-by: leesb971204 <[email protected]>
handleRedirectAndNotFound( | ||
this.getMatch(matchId)!, | ||
err, | ||
routerCode, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passes the routerCode
, which was previously included in err
, as a separate parameter to _handleNotFound
.
fixes #4707, #4708