File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -249,13 +249,16 @@ export function useConnection({
249
249
}
250
250
} ;
251
251
252
- const handleAuthError = async ( error : unknown ) => {
253
- const is401Error =
252
+ const is401Error = ( error : unknown ) : boolean => {
253
+ return (
254
254
( error instanceof SseError && error . code === 401 ) ||
255
255
( error instanceof Error && error . message . includes ( "401" ) ) ||
256
- ( error instanceof Error && error . message . includes ( "Unauthorized" ) ) ;
256
+ ( error instanceof Error && error . message . includes ( "Unauthorized" ) )
257
+ ) ;
258
+ } ;
257
259
258
- if ( is401Error ) {
260
+ const handleAuthError = async ( error : unknown ) => {
261
+ if ( is401Error ( error ) ) {
259
262
const serverAuthProvider = new InspectorOAuthClientProvider ( sseUrl ) ;
260
263
261
264
const result = await auth ( serverAuthProvider , { serverUrl : sseUrl } ) ;
@@ -432,12 +435,7 @@ export function useConnection({
432
435
if ( shouldRetry ) {
433
436
return connect ( undefined , retryCount + 1 ) ;
434
437
}
435
- const is401Error =
436
- ( error instanceof SseError && error . code === 401 ) ||
437
- ( error instanceof Error && error . message . includes ( "401" ) ) ||
438
- ( error instanceof Error && error . message . includes ( "Unauthorized" ) ) ;
439
-
440
- if ( is401Error ) {
438
+ if ( is401Error ( error ) ) {
441
439
// Don't set error state if we're about to redirect for auth
442
440
443
441
return ;
You can’t perform that action at this time.
0 commit comments