Skip to content

Commit 7b99a27

Browse files
fix(desktop): time out stuck Builderlab sign-in with a recovery path
Signed-off-by: Taksh <[email protected]> Co-authored-by: Cursor <[email protected]>
1 parent 13ddcbb commit 7b99a27

1 file changed

Lines changed: 40 additions & 9 deletions

File tree

‎desktop/src/features/communities/ui/HostedCommunityOnboarding.tsx‎

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ const PAGE_BACK_CLASS =
5555
const MODAL_PRIMARY_ACTION_CLASS = `${ONBOARDING_PRIMARY_CTA_CLASS} !text-[rgb(var(--buzz-hosted-community-modal-action-fg))]`;
5656
const MODAL_BACK_ACTION_CLASS =
5757
"h-9 rounded-full bg-foreground/10 px-6 hover:bg-foreground/15";
58+
/** Hosted Builderlab OAuth can hang forever on TLS/network failures (#2484). */
59+
const BUILDERLAB_SIGN_IN_TIMEOUT_MS = 45_000;
5860

5961
type HostedCommunityOnboardingProps = {
6062
onBack: () => void;
@@ -135,18 +137,35 @@ export function HostedCommunityOnboarding({
135137
const attempt = ++loginAttempt.current;
136138
setAction("Signing in…");
137139
setError(null);
138-
void startBuilderlabLogin()
140+
let timeoutId = 0;
141+
const timeout = new Promise<never>((_, reject) => {
142+
timeoutId = window.setTimeout(() => {
143+
reject(
144+
new Error(
145+
"Builderlab sign-in timed out. Retry, or go back and connect to an existing / self-hosted relay.",
146+
),
147+
);
148+
}, BUILDERLAB_SIGN_IN_TIMEOUT_MS);
149+
});
150+
void Promise.race([startBuilderlabLogin(), timeout])
139151
.then(async (nextAuth) => {
152+
window.clearTimeout(timeoutId);
140153
if (loginAttempt.current !== attempt) return;
141154
setAuth(nextAuth);
142155
await loadAccount();
143156
})
144157
.catch((cause) => {
158+
window.clearTimeout(timeoutId);
145159
if (loginAttempt.current !== attempt) return;
160+
// Invalidate any late success from the still-running native login.
161+
loginAttempt.current += 1;
146162
setError(cause instanceof Error ? cause.message : String(cause));
163+
void cancelBuilderlabLogin().catch(() => {
164+
// Best-effort cleanup when the browser flow never returns.
165+
});
147166
})
148167
.finally(() => {
149-
if (loginAttempt.current === attempt) setAction(null);
168+
setAction((current) => (current === "Signing in…" ? null : current));
150169
});
151170
};
152171

@@ -496,18 +515,30 @@ export function HostedCommunityOnboarding({
496515
Waiting for your browser…
497516
</Button>
498517
) : (
499-
<Button
500-
className={`mt-6 ${MODAL_PRIMARY_ACTION_CLASS}`}
501-
onClick={signIn}
502-
>
503-
Sign in to continue
504-
</Button>
518+
<div className="mt-6 flex w-full flex-col items-stretch gap-2">
519+
<Button
520+
className={MODAL_PRIMARY_ACTION_CLASS}
521+
onClick={signIn}
522+
>
523+
{error ? "Retry sign in" : "Sign in to continue"}
524+
</Button>
525+
{error ? (
526+
<Button
527+
className={MODAL_BACK_ACTION_CLASS}
528+
onClick={cancelSignInAndGoBack}
529+
variant="ghost"
530+
>
531+
Back — use another relay
532+
</Button>
533+
) : null}
534+
</div>
505535
)}
506536
{/* Quiet breadcrumb: Buzz itself is open source; this hosted
507537
relay is the one account-backed piece of the flow. */}
508538
<p className="mt-6 w-full border-t border-foreground/10 pt-4 text-xs leading-5 text-foreground/45">
509539
Buzz is open source. Builderlab hosts the relay for this
510-
account.
540+
account. If hosted setup fails, go back and connect to a
541+
self-hosted or existing relay instead.
511542
</p>
512543
</>
513544
) : !identity ? (

0 commit comments

Comments
 (0)