-
Notifications
You must be signed in to change notification settings - Fork 261
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
Found a few issues with navigation guards and fixed them #11190
Conversation
- The from/to routes were transposed so I flipped them - Load initial settings wasn't receiving the store and the error was swallowed. - Fixed some error reporting instead of just swallowing exceptions
d81e2ba
to
ccfc473
Compare
try { | ||
await fetchInitialSettings(); |
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.
This was never actually doing the heavy lifting. All the extra fetchIninitialSettings were actually doing the work. I fixed this and removed the others.
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.
In other words, we previously weren't fetching settings without a reference to the store?
@@ -294,7 +294,7 @@ export async function mountApp(appPartials, VueClass) { | |||
// Push the path and let route to be resolved | |||
router.push(path, undefined, (err) => { | |||
if (err) { | |||
const errorHandler = vueApp.config.errorHandler || console.error; // eslint-disable-line no-console | |||
const errorHandler = vueApp?.config?.errorHandler || console.error; // eslint-disable-line no-console |
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.
I've noticed a few times that this is being invoked without vueApp.config being defined.
} catch (ex) {} | ||
await fetchInitialSettings(store); | ||
} catch (e) { | ||
console.error('Failed fetching initial settings', e); // eslint-disable-line no-console |
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.
I left this blank because it was a part of the original code but it I accidentally changed the original code and this prevented me from noticing since the error wasn't emitted anywhere.
try { | ||
await fetchInitialSettings(); |
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.
In other words, we previously weren't fetching settings without a reference to the store?
@@ -147,8 +146,6 @@ export default { | |||
// For newer versions this will return all settings if you are somehow logged in, | |||
// and just the public ones if you aren't. | |||
try { | |||
await fetchInitialSettings(this.$store); |
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.
Do we want to remove these instances of fetchInitialSettings()
? I'm considering if they exist to act as a "refresh" in the event that something might have changed behind the scenes.
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.
For fetchInitialSettings
to act as a refresh instead of using our cache the dispatch methods used from within would need to be passed opt: { force: true }
. The second block is also actively skipped if it has ever been fetch since it's looking at generation
in the if statement.
Neither dispatch method seems to use this option so I figured that these usages aren't actually refreshing anything. If we'd like to put them back in for comfort I'm fine to do it but the above is why I decided to remove it. Let me know which you'd prefer.
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.
Your explanation helps to quell my fears and I'm not seeing a scenario where removing these instances causes a regression while testing this change. I think that we can leave them out.
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.
Settings are a special case. Requests when unauthed will result in a partial response, and when authed the full set.
To resolve this the UI uses load: _MULTI
resulting in the response being cached in the store... but not mark as having all results. So any subsequent calls to findAll will still make a http request (without specifying force
).
fetchInitialSettings
was put in place because we were fetching settings multiple times in different scenarios with the wrong props (resulting in multiple blocking requests on every fresh load).
Given the move of fetching settings outside of the authenticated middlware in #11165 it looks ok to remove these additional ones from brand, setup and login. However we need to validate
- setup flow works fine
- no additional settings requests are made (if unauthed 1 then another on log in, or only a single one on load when authed)
- parts that depends on settings continue to work (for example the brand is correctly applied on setup and logging pages)
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.
@richard-cox thanks for the info. A few questions about the additional testing:
setup flow works fine
- Are the tests in
dashboard/cypress/e2e/tests/setup/rancher-setup.spec.ts
sufficient for doing this?
parts that depends on settings continue to work (for example the brand is correctly applied on setup and logging pages)
- Do you mean something else other than setting up rancher (like in the tests I referenced above) when you say setup?
- What branding will be available before you've setup rancher? Which logging pages are you referring to?
- I have already verified that colors and favicons still work on the login page pre auth.
Quick note:
I've just verified that this is working as expected:
no additional settings requests are made (if unauthed 1 then another on log in, or only a single one on load when authed)
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.
Are the tests in dashboard/cypress/e2e/tests/setup/rancher-setup.spec.ts sufficient for doing this?
Good point! I wish whoever put them in remembered he put them in 🤦♂️ Apologies for churn.
Do you mean something else other than setting up rancher (like in the tests I referenced above) when you say setup?
Maybe we can skip this one. Branding (/v3/settings/ui-brand) will be applied either at install so will be seen in setup, or once setup in the UI (and setup is not returned to).
What branding will be available before you've setup rancher? Which logging pages are you referring to?
- I have already verified that colors and favicons still work on the login page pre auth.
That's the one
no additional settings requests are made (if unauthed 1 then another on log in, or only a single one on load when authed)
Perfect.
I think all bases are covered then, and it's really nice removing all those extra calls.
I don't know why I can't reply inline... This is mostly true, we weren't fetching settings from the intended location. It was getting called from the other locations which I removed in this PR. Those other call sites helped mask the issue that this wasn't getting called properly. |
Summary
While working on other changes I noticed that fetchInitialSettings was failing and was being swallowed by the try catch.
Checklist