Skip to content

Commit

Permalink
fix [object object] OOM error
Browse files Browse the repository at this point in the history
  • Loading branch information
Mary Hipp authored and psychedelicious committed Feb 10, 2025
1 parent 588e8a0 commit f3fbcf0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
18 changes: 7 additions & 11 deletions invokeai/frontend/web/src/features/toast/ErrorToastDescription.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import { Flex, IconButton, Text } from '@invoke-ai/ui-library';
import { useClipboard } from 'common/hooks/useClipboard';
import { ExternalLink } from 'features/gallery/components/ImageViewer/NoContentForViewer';
import { t } from 'i18next';
import { useCallback, useMemo } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import { PiCopyBold } from 'react-icons/pi';

type Props = { errorType: string; errorMessage?: string | null; sessionId: string; isLocal: boolean };
type DescriptionProps = { errorType: string; errorMessage?: string | null; sessionId: string; isLocal: boolean };

export const ErrorToastTitle = ({ errorType }: Props) => {
const { t } = useTranslation();

if (errorType === 'OutOfMemoryError') {
return <Text>{t('toast.outOfMemoryError')}</Text>;
}

return <Text>{t('toast.serverError')}</Text>;
export const getTitle = (errorType: string) => {
return errorType === 'OutOfMemoryError' ? t('toast.outOfMemoryError') : t('toast.serverError');
};

export default function ErrorToastDescription({ errorType, isLocal, sessionId, errorMessage }: Props) {
export default function ErrorToastDescription({ errorType, isLocal, sessionId, errorMessage }: DescriptionProps) {
const { t } = useTranslation();
const clipboard = useClipboard();

const description = useMemo(() => {
if (errorType === 'OutOfMemoryError') {
if (isLocal) {
Expand All @@ -39,7 +35,7 @@ export default function ErrorToastDescription({ errorType, isLocal, sessionId, e
}
}, [errorMessage, errorType, isLocal, t]);

const copySessionId = useCallback(() => clipboard.writeText(sessionId), [clipboard, sessionId]);
const copySessionId = useCallback(() => clipboard.writeText(sessionId), [sessionId, clipboard]);

return (
<Flex flexDir="column">
Expand Down
11 changes: 2 additions & 9 deletions invokeai/frontend/web/src/services/events/setEventListeners.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { AppStore } from 'app/store/store';
import { deepClone } from 'common/util/deepClone';
import { $nodeExecutionStates, upsertExecutionState } from 'features/nodes/hooks/useExecutionState';
import { zNodeStatus } from 'features/nodes/types/invocation';
import ErrorToastDescription, { ErrorToastTitle } from 'features/toast/ErrorToastDescription';
import ErrorToastDescription, { getTitle } from 'features/toast/ErrorToastDescription';
import { toast } from 'features/toast/toast';
import { t } from 'i18next';
import { forEach, isNil, round } from 'lodash-es';
Expand Down Expand Up @@ -400,14 +400,7 @@ export const setEventListeners = ({ socket, store, setIsConnected }: SetEventLis

toast({
id: `INVOCATION_ERROR_${error_type}`,
title: (
<ErrorToastTitle
errorType={error_type}
errorMessage={error_message}
sessionId={sessionId}
isLocal={isLocal}
/>
),
title: getTitle(error_type),
status: 'error',
duration: null,
updateDescription: isLocal,
Expand Down

0 comments on commit f3fbcf0

Please sign in to comment.