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({
249249 }
250250 } ;
251251
252- const handleAuthError = async ( error : unknown ) => {
253- const is401Error =
252+ const is401Error = ( error : unknown ) : boolean => {
253+ return (
254254 ( error instanceof SseError && error . code === 401 ) ||
255255 ( 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+ } ;
257259
258- if ( is401Error ) {
260+ const handleAuthError = async ( error : unknown ) => {
261+ if ( is401Error ( error ) ) {
259262 const serverAuthProvider = new InspectorOAuthClientProvider ( sseUrl ) ;
260263
261264 const result = await auth ( serverAuthProvider , { serverUrl : sseUrl } ) ;
@@ -432,12 +435,7 @@ export function useConnection({
432435 if ( shouldRetry ) {
433436 return connect ( undefined , retryCount + 1 ) ;
434437 }
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 ) ) {
441439 // Don't set error state if we're about to redirect for auth
442440
443441 return ;
You can’t perform that action at this time.
0 commit comments