Merge branch 'v2/main' into v2/fix/2217-oauth-clear-shared-url
This commit is contained in:
commit
7897d68cab
1 changed files with 105 additions and 6 deletions
|
|
@ -441,13 +441,31 @@ export function useOAuthRecovery({
|
|||
}
|
||||
let cancelled = false;
|
||||
|
||||
// Reads are concurrent — an `oauthComplete` can start a second one while
|
||||
// the first is still in flight — and nothing makes them settle in order.
|
||||
// Only the newest read may write, so a slow earlier one cannot overwrite
|
||||
// (or, on rejection, clear) a newer result.
|
||||
let latest = 0;
|
||||
|
||||
const refresh = (): void => {
|
||||
void inspectorClient.getOAuthState().then((state) => {
|
||||
if (cancelled) return;
|
||||
setConnectionInfoOAuthWhenConnected(
|
||||
state ? oauthDetailsFromConnectionState(state) : undefined,
|
||||
);
|
||||
});
|
||||
const seq = ++latest;
|
||||
// void: a synchronous useEffect body cannot await. The chain is
|
||||
// terminated below, so the rejection is handled rather than discarded.
|
||||
void inspectorClient
|
||||
.getOAuthState()
|
||||
.then((state) => {
|
||||
if (cancelled || seq !== latest) return;
|
||||
setConnectionInfoOAuthWhenConnected(
|
||||
state ? oauthDetailsFromConnectionState(state) : undefined,
|
||||
);
|
||||
})
|
||||
.catch(() => {
|
||||
// The read failed (backend down, 401 on the API token, malformed
|
||||
// stored state). Clear rather than keep the last successful read —
|
||||
// a stale answer is indistinguishable from a fresh one in the panel.
|
||||
if (cancelled || seq !== latest) return;
|
||||
setConnectionInfoOAuthWhenConnected(undefined);
|
||||
});
|
||||
};
|
||||
|
||||
const onAmbientAuthChallenge = (): void => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue