-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(u2f): Have authenticators GET wait for preloading to finish #71142
fix(u2f): Have authenticators GET wait for preloading to finish #71142
Conversation
This reverts commit 1a84b4d.
e3ad931
to
ef969ee
Compare
Bundle ReportChanges will increase total bundle size by 20.34kB ⬆️
|
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.
just nits, generally lgtm.
@@ -16,6 +16,15 @@ import useApi from 'sentry/utils/useApi'; | |||
import {useParams} from 'sentry/utils/useParams'; | |||
import {useRoutes} from 'sentry/utils/useRoutes'; | |||
|
|||
interface OrganizationLoaderContextProps { | |||
isLoading: boolean; | |||
loadOrganization: () => void; |
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.
it might be cool to have this return a Promise
rather than void, then you wouldn't need to maintain a separate isLoading
variable, instead you could just continue the promise chain and use the promises state to for the load state.
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.
is this how to do it? I suspect I might have it wrong using the promise directly in the useEffect
dependency array
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'd say this is like 99% there, i left a comment on the useEffect
but i think you can basically remove it and be good to go.
...prevState, | ||
authenticators: fetchedAuthenticators ?? [], | ||
})); | ||
loadOrganization().then(async () => { |
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 don't think we'll need this inside of a useEffect
, i believe you can just grab the loadOrganization.then(()
here instead.
This is because the OrganizationContextLoader
will initialize the promise chain, then here we're referencing the promise directly, so whenever the promise resolves it will call .then
.
@@ -16,6 +16,15 @@ import useApi from 'sentry/utils/useApi'; | |||
import {useParams} from 'sentry/utils/useParams'; | |||
import {useRoutes} from 'sentry/utils/useRoutes'; | |||
|
|||
interface OrganizationLoaderContextProps { | |||
isLoading: boolean; | |||
loadOrganization: () => void; |
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'd say this is like 99% there, i left a comment on the useEffect
but i think you can basically remove it and be good to go.
PR reverted: 1fc431c |
In order to have the U2F state be correctly set in the client browser session cookie, we need to wait for preloading requests to finish first to avoid a race condition. This was done by:
sudo modal
to a functional component so we can useuseContext
in it chore(staff): Convert sudo modal to functional #71100organizationLoadingContext
chore(context): Track progress of preloading requests #71112Note that the PRs mentioned above must be merged first
Local Example
take_two.mov