@@ -11,12 +11,35 @@ import { socketInvocationError } from 'services/events/actions';
11
11
12
12
const log = logger ( 'socketio' ) ;
13
13
14
+ const getTitle = ( errorType : string ) => {
15
+ if ( errorType === 'OutOfMemoryError' ) {
16
+ return t ( 'toast.outOfMemoryError' ) ;
17
+ }
18
+ return t ( 'toast.serverError' ) ;
19
+ } ;
20
+
21
+ const getDescription = ( errorType : string , sessionId : string , isLocal ?: boolean ) => {
22
+ if ( ! isLocal ) {
23
+ if ( errorType === 'OutOfMemoryError' ) {
24
+ return ToastWithSessionRefDescription ( {
25
+ message : t ( 'toast.outOfMemoryDescription' ) ,
26
+ sessionId,
27
+ } ) ;
28
+ }
29
+ return ToastWithSessionRefDescription ( {
30
+ message : errorType ,
31
+ sessionId,
32
+ } ) ;
33
+ }
34
+ return errorType ;
35
+ } ;
36
+
14
37
export const addInvocationErrorEventListener = ( startAppListening : AppStartListening ) => {
15
38
startAppListening ( {
16
39
actionCreator : socketInvocationError ,
17
- effect : ( action ) => {
40
+ effect : ( action , { getState } ) => {
18
41
log . error ( action . payload , `Invocation error (${ action . payload . data . node . type } )` ) ;
19
- const { source_node_id, error_type } = action . payload . data ;
42
+ const { source_node_id, error_type, graph_execution_state_id } = action . payload . data ;
20
43
const nes = deepClone ( $nodeExecutionStates . get ( ) [ source_node_id ] ) ;
21
44
if ( nes ) {
22
45
nes . status = zNodeStatus . enum . FAILED ;
@@ -25,32 +48,19 @@ export const addInvocationErrorEventListener = (startAppListening: AppStartListe
25
48
nes . progressImage = null ;
26
49
upsertExecutionState ( nes . nodeId , nes ) ;
27
50
}
28
- const errorType = startCase ( action . payload . data . error_type ) ;
29
- const sessionId = action . payload . data . graph_execution_state_id ;
30
51
31
- if ( error_type === 'OutOfMemoryError' ) {
32
- toast ( {
33
- id : 'INVOCATION_ERROR' ,
34
- title : t ( 'toast.outOfMemoryError' ) ,
35
- status : 'error' ,
36
- duration : null ,
37
- description : ToastWithSessionRefDescription ( {
38
- message : t ( 'toast.outOfMemoryDescription' ) ,
39
- sessionId,
40
- } ) ,
41
- } ) ;
42
- } else {
43
- toast ( {
44
- id : `INVOCATION_ERROR_${ errorType } ` ,
45
- title : t ( 'toast.serverError' ) ,
46
- status : 'error' ,
47
- duration : null ,
48
- description : ToastWithSessionRefDescription ( {
49
- message : errorType ,
50
- sessionId,
51
- } ) ,
52
- } ) ;
53
- }
52
+ const errorType = startCase ( error_type ) ;
53
+ const sessionId = graph_execution_state_id ;
54
+ const { isLocal } = getState ( ) . config ;
55
+
56
+ toast ( {
57
+ id : `INVOCATION_ERROR_${ errorType } ` ,
58
+ title : getTitle ( errorType ) ,
59
+ status : 'error' ,
60
+ duration : null ,
61
+ description : getDescription ( errorType , sessionId , isLocal ) ,
62
+ updateDescription : isLocal ? true : false ,
63
+ } ) ;
54
64
} ,
55
65
} ) ;
56
66
} ;
0 commit comments