Skip to content

Commit 2658107

Browse files
committed
fix(oauth): wrap completeConnect in try/catch to handle thrown errors
If completeConnect throws (not just returns false), UI would get stuck in 'processing' state. Now catches exceptions and shows error message.
1 parent 7729719 commit 2658107

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

frontend/src/pages/GitHubCallbackPage.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,26 @@ export function GitHubCallbackPage() {
4444
}
4545

4646
// Exchange code for token via backend
47-
const success = await completeConnect(code, state);
48-
49-
if (!mounted) return;
50-
51-
if (success) {
52-
setStatus('success');
53-
timeoutRef.current = setTimeout(() => {
54-
if (mounted) {
55-
navigate('/dashboard', { replace: true });
56-
}
57-
}, 1500);
58-
} else {
47+
try {
48+
const success = await completeConnect(code, state);
49+
50+
if (!mounted) return;
51+
52+
if (success) {
53+
setStatus('success');
54+
timeoutRef.current = setTimeout(() => {
55+
if (mounted) {
56+
navigate('/dashboard', { replace: true });
57+
}
58+
}, 1500);
59+
} else {
60+
setStatus('error');
61+
setErrorMessage('Failed to connect GitHub account');
62+
}
63+
} catch (err) {
64+
if (!mounted) return;
5965
setStatus('error');
60-
setErrorMessage('Failed to connect GitHub account');
66+
setErrorMessage(err instanceof Error ? err.message : 'An unexpected error occurred');
6167
}
6268
};
6369

0 commit comments

Comments
 (0)