-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
fix(vue-app): fix exception on property access of undefined object #5867
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
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #5867 +/- ##
=======================================
Coverage 95.68% 95.68%
=======================================
Files 82 82
Lines 2690 2690
Branches 690 690
=======================================
Hits 2574 2574
Misses 98 98
Partials 18 18
Continue to review full report at Codecov.
|
@clarkdo please review |
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.
@rchl Good catch.
The checking is necessary, but I suggest returning first if matchedRoute
is undefined.
const [matchedRoute] = this.$route.matched
if (!matchedRoute) {
return this.$route.path
}
const Component = matchedRoute && matchedRoute.components.default
// ...
After PR #5746, which has added code to remove trailing slash in non-strict mode, I've gotten exception reported through Sentry due to trying to get proper 'path' of undefined 'matchedRoute' object. I don't know how it happens but it's clear error as code above checks for null `matchedRoute` but not the code that checks for trailing slash. Made the logic so that non-replaced path is returned when no route matches. Same as before original fix.
@rchl Thanks |
@pimlie No, I'm not using nested routes (nuxtChild I presume). It only happened once though and it is nothing given number of requests. I get strangest errors reported by Sentry browser client anyway... |
Types of changes
Description
After PR #5746, which has added code to remove trailing slash
in non-strict mode, I've gotten exception reported through Sentry due to
trying to get proper 'path' of undefined 'matchedRoute' object.
I don't know how it happens but it's clear error as code above checks
for null
matchedRoute
but not the code that checks for trailing slash.Made the logic so that non-replaced path is returned when no route
matches. Same as before original fix.
Follow-up fix to #5593
Checklist: