mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): revised invocation error toast handling
Only display the session if local. Otherwise, just display the error message.
This commit is contained in:
parent
57743239d7
commit
abc133e936
@ -11,12 +11,35 @@ import { socketInvocationError } from 'services/events/actions';
|
|||||||
|
|
||||||
const log = logger('socketio');
|
const log = logger('socketio');
|
||||||
|
|
||||||
|
const getTitle = (errorType: string) => {
|
||||||
|
if (errorType === 'OutOfMemoryError') {
|
||||||
|
return t('toast.outOfMemoryError');
|
||||||
|
}
|
||||||
|
return t('toast.serverError');
|
||||||
|
};
|
||||||
|
|
||||||
|
const getDescription = (errorType: string, sessionId: string, isLocal?: boolean) => {
|
||||||
|
if (!isLocal) {
|
||||||
|
if (errorType === 'OutOfMemoryError') {
|
||||||
|
return ToastWithSessionRefDescription({
|
||||||
|
message: t('toast.outOfMemoryDescription'),
|
||||||
|
sessionId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return ToastWithSessionRefDescription({
|
||||||
|
message: errorType,
|
||||||
|
sessionId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return errorType;
|
||||||
|
};
|
||||||
|
|
||||||
export const addInvocationErrorEventListener = (startAppListening: AppStartListening) => {
|
export const addInvocationErrorEventListener = (startAppListening: AppStartListening) => {
|
||||||
startAppListening({
|
startAppListening({
|
||||||
actionCreator: socketInvocationError,
|
actionCreator: socketInvocationError,
|
||||||
effect: (action) => {
|
effect: (action, { getState }) => {
|
||||||
log.error(action.payload, `Invocation error (${action.payload.data.node.type})`);
|
log.error(action.payload, `Invocation error (${action.payload.data.node.type})`);
|
||||||
const { source_node_id, error_type } = action.payload.data;
|
const { source_node_id, error_type, graph_execution_state_id } = action.payload.data;
|
||||||
const nes = deepClone($nodeExecutionStates.get()[source_node_id]);
|
const nes = deepClone($nodeExecutionStates.get()[source_node_id]);
|
||||||
if (nes) {
|
if (nes) {
|
||||||
nes.status = zNodeStatus.enum.FAILED;
|
nes.status = zNodeStatus.enum.FAILED;
|
||||||
@ -25,32 +48,19 @@ export const addInvocationErrorEventListener = (startAppListening: AppStartListe
|
|||||||
nes.progressImage = null;
|
nes.progressImage = null;
|
||||||
upsertExecutionState(nes.nodeId, nes);
|
upsertExecutionState(nes.nodeId, nes);
|
||||||
}
|
}
|
||||||
const errorType = startCase(action.payload.data.error_type);
|
|
||||||
const sessionId = action.payload.data.graph_execution_state_id;
|
|
||||||
|
|
||||||
if (error_type === 'OutOfMemoryError') {
|
const errorType = startCase(error_type);
|
||||||
toast({
|
const sessionId = graph_execution_state_id;
|
||||||
id: 'INVOCATION_ERROR',
|
const { isLocal } = getState().config;
|
||||||
title: t('toast.outOfMemoryError'),
|
|
||||||
status: 'error',
|
|
||||||
duration: null,
|
|
||||||
description: ToastWithSessionRefDescription({
|
|
||||||
message: t('toast.outOfMemoryDescription'),
|
|
||||||
sessionId,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
toast({
|
toast({
|
||||||
id: `INVOCATION_ERROR_${errorType}`,
|
id: `INVOCATION_ERROR_${errorType}`,
|
||||||
title: t('toast.serverError'),
|
title: getTitle(errorType),
|
||||||
status: 'error',
|
status: 'error',
|
||||||
duration: null,
|
duration: null,
|
||||||
description: ToastWithSessionRefDescription({
|
description: getDescription(errorType, sessionId, isLocal),
|
||||||
message: errorType,
|
updateDescription: isLocal ? true : false,
|
||||||
sessionId,
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user