This is an automated email from the ASF dual-hosted git repository.

rfellows pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new e9cb00bd11 NIFI-13382: (#8957)
e9cb00bd11 is described below

commit e9cb00bd11d2a0539ea8b19f1e8d42d096f48a72
Author: Matt Gilman <[email protected]>
AuthorDate: Fri Jun 14 10:04:53 2024 -0400

    NIFI-13382: (#8957)
    
    - Showing a full page error when the front end can no longer communicate 
with the back end.
    
    This closes #8957
---
 .../app/service/interceptors/auth.interceptor.ts   |  6 ++---
 .../service/interceptors/polling.interceptor.ts    | 28 +++++++++++++++-------
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git 
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/service/interceptors/auth.interceptor.ts
 
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/service/interceptors/auth.interceptor.ts
index 7b003d886d..d7b64a43c9 100644
--- 
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/service/interceptors/auth.interceptor.ts
+++ 
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/service/interceptors/auth.interceptor.ts
@@ -17,7 +17,7 @@
 
 import { inject } from '@angular/core';
 import { HttpErrorResponse, HttpHandlerFn, HttpInterceptorFn, HttpRequest } 
from '@angular/common/http';
-import { catchError, map, take, combineLatest, tap } from 'rxjs';
+import { catchError, take, combineLatest, tap, NEVER, switchMap } from 'rxjs';
 import { Store } from '@ngrx/store';
 import { NiFiState } from '../../state';
 import { fullScreenError, setRoutedToFullScreenError } from 
'../../state/error/error.actions';
@@ -43,7 +43,7 @@ export const authInterceptor: HttpInterceptorFn = (request: 
HttpRequest<unknown>
                         tap(() => store.dispatch(setRoutedToFullScreenError({ 
routedToFullScreenError: true })))
                     )
                 ]).pipe(
-                    map(([currentUserState, loginConfiguration, 
routedToFullScreenError]) => {
+                    switchMap(([currentUserState, loginConfiguration, 
routedToFullScreenError]) => {
                         if (
                             currentUserState.status === 'pending' &&
                             loginConfiguration?.loginSupported &&
@@ -61,7 +61,7 @@ export const authInterceptor: HttpInterceptorFn = (request: 
HttpRequest<unknown>
                             );
                         }
 
-                        throw errorResponse;
+                        return NEVER;
                     })
                 );
             } else {
diff --git 
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/service/interceptors/polling.interceptor.ts
 
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/service/interceptors/polling.interceptor.ts
index c444c2caa0..9862a3bc11 100644
--- 
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/service/interceptors/polling.interceptor.ts
+++ 
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/service/interceptors/polling.interceptor.ts
@@ -17,24 +17,36 @@
 
 import { inject } from '@angular/core';
 import { HttpErrorResponse, HttpHandlerFn, HttpInterceptorFn, HttpRequest } 
from '@angular/common/http';
-import { tap } from 'rxjs';
+import { catchError, NEVER } from 'rxjs';
 import { NiFiState } from '../../state';
 import { Store } from '@ngrx/store';
 import { stopCurrentUserPolling } from 
'../../state/current-user/current-user.actions';
 import { stopProcessGroupPolling } from 
'../../pages/flow-designer/state/flow/flow.actions';
 import { stopClusterSummaryPolling } from 
'../../state/cluster-summary/cluster-summary.actions';
+import { fullScreenError } from '../../state/error/error.actions';
 
 export const pollingInterceptor: HttpInterceptorFn = (request: 
HttpRequest<unknown>, next: HttpHandlerFn) => {
     const store: Store<NiFiState> = inject(Store<NiFiState>);
 
     return next(request).pipe(
-        tap({
-            error: (error) => {
-                if (error instanceof HttpErrorResponse && error.status === 0) {
-                    store.dispatch(stopCurrentUserPolling());
-                    store.dispatch(stopProcessGroupPolling());
-                    store.dispatch(stopClusterSummaryPolling());
-                }
+        catchError((errorResponse) => {
+            if (errorResponse instanceof HttpErrorResponse && 
errorResponse.status === 0) {
+                store.dispatch(stopCurrentUserPolling());
+                store.dispatch(stopProcessGroupPolling());
+                store.dispatch(stopClusterSummaryPolling());
+
+                store.dispatch(
+                    fullScreenError({
+                        errorDetail: {
+                            title: 'Unable to communicate with NiFi',
+                            message: 'Please ensure the application is running 
and check the logs for any errors.'
+                        }
+                    })
+                );
+
+                return NEVER;
+            } else {
+                throw errorResponse;
             }
         })
     );

Reply via email to