mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
surface usage errors for cnet and upscale, handle clearing cnet if error occurs
This commit is contained in:
parent
807c6b41c5
commit
40ed218c26
@ -1,7 +1,11 @@
|
|||||||
import { logger } from 'app/logging/logger';
|
import { logger } from 'app/logging/logger';
|
||||||
import { parseify } from 'common/util/serialize';
|
import { parseify } from 'common/util/serialize';
|
||||||
import { controlNetImageProcessed } from 'features/controlNet/store/actions';
|
import { controlNetImageProcessed } from 'features/controlNet/store/actions';
|
||||||
import { controlNetProcessedImageChanged } from 'features/controlNet/store/controlNetSlice';
|
import {
|
||||||
|
clearPendingControlImages,
|
||||||
|
controlNetImageChanged,
|
||||||
|
controlNetProcessedImageChanged,
|
||||||
|
} from 'features/controlNet/store/controlNetSlice';
|
||||||
import { SAVE_IMAGE } from 'features/nodes/util/graphBuilders/constants';
|
import { SAVE_IMAGE } from 'features/nodes/util/graphBuilders/constants';
|
||||||
import { addToast } from 'features/system/store/systemSlice';
|
import { addToast } from 'features/system/store/systemSlice';
|
||||||
import { t } from 'i18next';
|
import { t } from 'i18next';
|
||||||
@ -11,6 +15,7 @@ import { isImageOutput } from 'services/api/guards';
|
|||||||
import { Graph, ImageDTO } from 'services/api/types';
|
import { Graph, ImageDTO } from 'services/api/types';
|
||||||
import { socketInvocationComplete } from 'services/events/actions';
|
import { socketInvocationComplete } from 'services/events/actions';
|
||||||
import { startAppListening } from '..';
|
import { startAppListening } from '..';
|
||||||
|
import { FetchBaseQueryError } from '@reduxjs/toolkit/dist/query';
|
||||||
|
|
||||||
export const addControlNetImageProcessedListener = () => {
|
export const addControlNetImageProcessedListener = () => {
|
||||||
startAppListening({
|
startAppListening({
|
||||||
@ -105,8 +110,31 @@ export const addControlNetImageProcessedListener = () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch {
|
} catch (error) {
|
||||||
log.error({ graph: parseify(graph) }, t('queue.graphFailedToQueue'));
|
log.error({ graph: parseify(graph) }, t('queue.graphFailedToQueue'));
|
||||||
|
|
||||||
|
// handle usage-related errors
|
||||||
|
if (error instanceof Object) {
|
||||||
|
if ('data' in error && 'status' in error) {
|
||||||
|
if (error.status === 403) {
|
||||||
|
const detail = (error.data as any)?.detail || 'Unknown Error';
|
||||||
|
dispatch(
|
||||||
|
addToast({
|
||||||
|
title: t('queue.graphFailedToQueue'),
|
||||||
|
status: 'error',
|
||||||
|
description: detail,
|
||||||
|
duration: 15000,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
dispatch(clearPendingControlImages());
|
||||||
|
dispatch(
|
||||||
|
controlNetImageChanged({ controlNetId, controlImage: null })
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
addToast({
|
addToast({
|
||||||
title: t('queue.graphFailedToQueue'),
|
title: t('queue.graphFailedToQueue'),
|
||||||
|
@ -44,8 +44,27 @@ export const addUpscaleRequestedListener = () => {
|
|||||||
{ enqueueResult: parseify(enqueueResult) },
|
{ enqueueResult: parseify(enqueueResult) },
|
||||||
t('queue.graphQueued')
|
t('queue.graphQueued')
|
||||||
);
|
);
|
||||||
} catch {
|
} catch (error) {
|
||||||
log.error({ graph: parseify(graph) }, t('queue.graphFailedToQueue'));
|
log.error({ graph: parseify(graph) }, t('queue.graphFailedToQueue'));
|
||||||
|
|
||||||
|
// handle usage-related errors
|
||||||
|
if (error instanceof Object) {
|
||||||
|
if ('data' in error && 'status' in error) {
|
||||||
|
if (error.status === 403) {
|
||||||
|
const detail = (error.data as any)?.detail || 'Unknown Error';
|
||||||
|
dispatch(
|
||||||
|
addToast({
|
||||||
|
title: t('queue.graphFailedToQueue'),
|
||||||
|
status: 'error',
|
||||||
|
description: detail,
|
||||||
|
duration: 15000,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
addToast({
|
addToast({
|
||||||
title: t('queue.graphFailedToQueue'),
|
title: t('queue.graphFailedToQueue'),
|
||||||
|
@ -410,6 +410,9 @@ export const controlNetSlice = createSlice({
|
|||||||
state.isIPAdapterEnabled = false;
|
state.isIPAdapterEnabled = false;
|
||||||
state.ipAdapterInfo = { ...initialIPAdapterState };
|
state.ipAdapterInfo = { ...initialIPAdapterState };
|
||||||
},
|
},
|
||||||
|
clearPendingControlImages: (state) => {
|
||||||
|
state.pendingControlImages = [];
|
||||||
|
},
|
||||||
},
|
},
|
||||||
extraReducers: (builder) => {
|
extraReducers: (builder) => {
|
||||||
builder.addCase(controlNetImageProcessed, (state, action) => {
|
builder.addCase(controlNetImageProcessed, (state, action) => {
|
||||||
@ -474,6 +477,7 @@ export const {
|
|||||||
ipAdapterBeginStepPctChanged,
|
ipAdapterBeginStepPctChanged,
|
||||||
ipAdapterEndStepPctChanged,
|
ipAdapterEndStepPctChanged,
|
||||||
ipAdapterStateReset,
|
ipAdapterStateReset,
|
||||||
|
clearPendingControlImages,
|
||||||
} = controlNetSlice.actions;
|
} = controlNetSlice.actions;
|
||||||
|
|
||||||
export default controlNetSlice.reducer;
|
export default controlNetSlice.reducer;
|
||||||
|
Loading…
Reference in New Issue
Block a user