Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

feat(webv2): instrument transport, queue, persistence, widgets, and features

Josh Corbett3fac46719611
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryUploadAction.ts b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryUploadAction.ts
index 2449bb6bcb..236bb3320d 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryUploadAction.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryUploadAction.ts
@@ -9,6 +9,7 @@ import {
} from '@features/gallery/core/items';
import { isDateBoardId, uploadGalleryImage, uploadGalleryVideo } from '@features/gallery/data/backend';
import { invalidateGallery } from '@features/gallery/data/queryCache';
+import { createLogger } from '@platform/logging/logger';
import {
assertAccountScopeCurrent,
captureAccountScope,
@@ -24,6 +25,7 @@ import type { GalleryActions } from './GalleryWidgetContext';
import { useGalleryUi } from './GalleryUiContext';
const toErrorMessage = (error: unknown): string => (error instanceof Error ? error.message : String(error));
+const uploadLogger = createLogger({ area: 'upload', namespace: 'gallery' });
export const useGalleryUploadAction = ({
boards,
@@ -120,14 +122,33 @@ export const useGalleryUploadAction = ({
const uploadedVideos = videoResults.flatMap((result) => (result.status === 'fulfilled' ? [result.value] : []));
const uploadedItems = [...uploadedImages, ...uploadedVideos];
const failedCount = files.length - uploadedItems.length;
+ const firstRejection = [...imageResults, ...videoResults].find((result) => result.status === 'rejected');
+
+ // A total failure is reported once, by the notification path below.
+ if (uploadedItems.length > 0) {
+ uploadLogger[failedCount > 0 ? 'warn' : 'info']({
+ context: {
+ boardId: targetBoardId,
+ failed: failedCount,
+ images: uploadedImages.length,
+ requested: files.length,
+ videos: uploadedVideos.length,
+ },
+ error: firstRejection?.reason,
+ message:
+ failedCount > 0
+ ? `Uploaded ${uploadedItems.length} of ${files.length} files`
+ : `Uploaded ${uploadedItems.length} files`,
+ name: failedCount > 0 ? 'gallery.upload-partial' : 'gallery.upload-completed',
+ });
+ }
if (uploadedItems.length === 0) {
const fallback = t('widgets.gallery.uploadFailed', { failed: failedCount });
- const firstFailure = [...imageResults, ...videoResults].find((result) => result.status === 'rejected');
notifications.reportError({
area: 'gallery-upload',
- message: firstFailure ? getApiErrorMessage(firstFailure.reason, fallback) : fallback,
+ message: firstRejection ? getApiErrorMessage(firstRejection.reason, fallback) : fallback,
namespace: 'gallery',
});
return [];
diff --git a/invokeai/frontend/webv2/src/features/models/data/installsStore.ts b/invokeai/frontend/webv2/src/features/models/data/installsStore.ts
index 9a06f0c8ec..020d751e02 100644
--- a/invokeai/frontend/webv2/src/features/models/data/installsStore.ts
+++ b/invokeai/frontend/webv2/src/features/models/data/installsStore.ts
@@ -1,5 +1,6 @@
import type { ModelInstallJob, ModelInstallStatus } from '@features/models/core/types';
+import { createLogger } from '@platform/logging/logger';
import {
type AccountScope,
captureAccountScope,
@@ -127,6 +128,11 @@ export const refreshInstalls = (owner: AccountScope = captureAccountScope()): Pr
return;
}
+ installLogger.warn({
+ error,
+ message: 'Failed to load the install queue',
+ name: 'models.install-queue-load-failed',
+ });
store.patchSnapshot({
error: getApiErrorMessage(error, 'Failed to load install queue.'),
status: store.getSnapshot().jobs.length > 0 ? 'loaded' : 'error',
@@ -184,7 +190,28 @@ export const addInstallJob = (job: ModelInstallJob): void => {
store.patchSnapshot({ jobs: [job, ...store.getSnapshot().jobs], status: 'loaded' });
};
+const installLogger = createLogger({ area: 'install', namespace: 'models' });
+
const recordOutcome = (outcome: Omit<InstallOutcome, 'id'>): void => {
+ const context = { jobId: outcome.jobId, modelName: outcome.modelName, source: outcome.source };
+
+ if (outcome.kind === 'error') {
+ installLogger.error({
+ context: { ...context, reason: outcome.error },
+ message: `Model install failed: ${outcome.source}`,
+ name: 'models.install-failed',
+ });
+ } else {
+ installLogger.info({
+ context,
+ message:
+ outcome.kind === 'completed'
+ ? `Model installed: ${outcome.source}`
+ : `Model install cancelled: ${outcome.source}`,
+ name: outcome.kind === 'completed' ? 'models.install-completed' : 'models.install-cancelled',
+ });
+ }
+
outcomesStore.patchSnapshot({
outcomes: [{ ...outcome, id: nextOutcomeId }, ...outcomesStore.getSnapshot().outcomes].slice(0, OUTCOME_LIMIT),
});
diff --git a/invokeai/frontend/webv2/src/features/queue/runtime/coordinator.ts b/invokeai/frontend/webv2/src/features/queue/runtime/coordinator.ts
index 10d0958601..bce22d2cdc 100644
--- a/invokeai/frontend/webv2/src/features/queue/runtime/coordinator.ts
+++ b/invokeai/frontend/webv2/src/features/queue/runtime/coordinator.ts
@@ -32,11 +32,15 @@ import {
} from '@features/queue/data/progressImageStore';
import { queueItemProgressStore, type QueueItemProgressSink } from '@features/queue/data/progressStore';
import { mapWithConcurrency } from '@platform/core/concurrency';
+import { createLogger } from '@platform/logging/logger';
import { captureAccountScope, isAccountScopeCurrent } from '@platform/state/accountLifecycle';
import { ApiError } from '@platform/transport/http';
const GALLERY_REFRESH_COALESCE_MS = 400;
const SAFETY_SWEEP_INTERVAL_MS = 30_000;
+/** Node-level detail supports the terminal queue-item failure the history owner records. */
+const coordinatorLogger = createLogger({ area: 'coordinator', namespace: 'queue' });
+
const TERMINAL_EVENT_BUFFER_LIMIT = 256;
const NODE_EVENT_BUFFER_ITEM_LIMIT = 64;
const NODE_EVENT_BUFFER_EVENTS_PER_ITEM = 512;
@@ -379,6 +383,17 @@ export const createQueueCoordinator = (
nodeExecution.completed(nodeEvent.event);
return;
case 'failed':
+ coordinatorLogger.debug({
+ context: {
+ errorMessage: nodeEvent.event.error_message,
+ errorType: nodeEvent.event.error_type,
+ itemId: nodeEvent.event.item_id,
+ nodeId: nodeEvent.event.invocation_source_id,
+ sessionId: nodeEvent.event.session_id,
+ },
+ message: `Invocation failed: ${nodeEvent.event.error_type}`,
+ name: 'queue.invocation-error',
+ });
nodeExecution.failed(nodeEvent.event);
return;
}
diff --git a/invokeai/frontend/webv2/src/features/workflow/data/libraryBrowseStore.ts b/invokeai/frontend/webv2/src/features/workflow/data/libraryBrowseStore.ts
index b4f7822dbe..93e89a5ee2 100644
--- a/invokeai/frontend/webv2/src/features/workflow/data/libraryBrowseStore.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/data/libraryBrowseStore.ts
@@ -6,6 +6,7 @@ import type { AccountScope } from '@platform/state/accountLifecycle';
import { parseWorkflowTags, sortTagCounts } from '@features/workflow/core/libraryTags';
import { extractWorkflowModelRequirements } from '@features/workflow/core/modelRequirements';
import { parseWorkflowJson } from '@features/workflow/core/workflowJson';
+import { createLogger } from '@platform/logging/logger';
import {
captureAccountScope,
isAccountScopeCurrent,
@@ -22,6 +23,8 @@ import { getAllWorkflowTags, getWorkflowTagCounts, listLibraryWorkflows } from '
import { getLibraryWorkflowCached, onWorkflowLibraryCacheInvalidated } from './libraryCache';
import { getInvocationTemplatesSnapshot, refreshInvocationTemplates } from './templates';
+const libraryLogger = createLogger({ area: 'library', namespace: 'workflows' });
+
/**
* Filter and paginate server-side; asynchronously enrich cached payloads per row so node/model details cannot
* block the grid.
@@ -220,6 +223,12 @@ const enrichEntry = async (workflowId: string, owner: AccountScope): Promise<voi
);
} catch (error) {
// One unreadable workflow marks its own card and never fails the pool.
+ libraryLogger.warn({
+ context: { workflowId },
+ error,
+ message: 'Failed to read a library workflow',
+ name: 'workflows.library-read-failed',
+ });
applyEnrichment(
workflowId,
{ message: getApiErrorMessage(error, 'Failed to read this workflow.'), status: 'error' },
@@ -286,6 +295,11 @@ const loadFirstPage = async (filter: WorkflowLibraryBrowseFilter, owner: Account
}
} catch (error) {
if (isFilterCurrent(generation, owner)) {
+ libraryLogger.warn({
+ error,
+ message: 'Failed to load workflows',
+ name: 'workflows.library-load-failed',
+ });
store.patchSnapshot({ error: getApiErrorMessage(error, 'Failed to load workflows.'), status: 'error' });
}
}
@@ -302,6 +316,11 @@ const loadMorePages = async (filter: WorkflowLibraryBrowseFilter, page: number,
}
} catch (error) {
if (isFilterCurrent(generation, owner)) {
+ libraryLogger.warn({
+ error,
+ message: 'Failed to load more workflows',
+ name: 'workflows.library-load-failed',
+ });
store.patchSnapshot({ error: getApiErrorMessage(error, 'Failed to load more workflows.'), status: 'error' });
}
}
@@ -446,6 +465,11 @@ export const refreshWorkflowLibraryBrowse = (): Promise<void> =>
}
} catch (error) {
if (isFilterCurrent(generation, owner)) {
+ libraryLogger.warn({
+ error,
+ message: 'Failed to refresh workflows',
+ name: 'workflows.library-load-failed',
+ });
store.patchSnapshot({ error: getApiErrorMessage(error, 'Failed to refresh workflows.'), status: 'error' });
}
}
diff --git a/invokeai/frontend/webv2/src/features/workflow/data/templates.ts b/invokeai/frontend/webv2/src/features/workflow/data/templates.ts
index 0177509a59..adfcad6d1f 100644
--- a/invokeai/frontend/webv2/src/features/workflow/data/templates.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/data/templates.ts
@@ -7,6 +7,7 @@ import type {
InvocationTemplatesSnapshot,
} from '@features/workflow/core/types';
+import { createLogger } from '@platform/logging/logger';
import {
captureAccountScope,
isAccountScopeCurrent,
@@ -426,6 +427,11 @@ export const refreshInvocationTemplates = async (): Promise<void> => {
return;
}
+ createLogger({ area: 'templates', namespace: 'workflows' }).error({
+ error,
+ message: 'Failed to load node definitions',
+ name: 'workflows.templates-load-failed',
+ });
store.patchSnapshot({
error: getApiErrorMessage(error, 'Failed to load node definitions from the backend.'),
status: 'error',
diff --git a/invokeai/frontend/webv2/src/platform/transport/http.test.ts b/invokeai/frontend/webv2/src/platform/transport/http.test.ts
index b04b917ad2..633676cf8f 100644
--- a/invokeai/frontend/webv2/src/platform/transport/http.test.ts
+++ b/invokeai/frontend/webv2/src/platform/transport/http.test.ts
@@ -1,3 +1,6 @@
+import { DEFAULT_LOGGING_CONFIG } from '@platform/logging/contracts';
+import { configureLogging, getLogSnapshot, resetLogging } from '@platform/logging/logger';
+import { accountLifecycle } from '@platform/state/accountLifecycle';
import { beforeEach, describe, expect, it, vi } from 'vitest';
vi.mock('./deploymentBase', () => ({
@@ -175,6 +178,79 @@ describe('request identity ownership', () => {
});
});
+describe('transport diagnostics', () => {
+ beforeEach(() => {
+ const identity = {};
+ configureHttpAuth({ getIdentity: () => identity, getToken: () => null, onUnauthorized: vi.fn() });
+ resetLogging();
+ configureLogging({ ...DEFAULT_LOGGING_CONFIG, level: 'debug' });
+ });
+
+ it('records failed responses and network failures as debug breadcrumbs without query strings', async () => {
+ vi.stubGlobal(
+ 'fetch',
+ vi
+ .fn()
+ .mockResolvedValueOnce(new Response('{"detail":"nope"}', { status: 503 }))
+ .mockRejectedValueOnce(new TypeError('Failed to fetch'))
+ );
+
+ await expect(apiFetch('/api/v1/images?token=abc', { method: 'POST' })).rejects.toBeInstanceOf(ApiError);
+ await expect(apiFetch('/api/v1/boards')).rejects.toBeInstanceOf(TypeError);
+
+ expect(getLogSnapshot().entries).toMatchObject([
+ {
+ error: { message: 'Failed to fetch', name: 'TypeError' },
+ level: 'debug',
+ name: 'http.request-failed',
+ source: { area: 'http', namespace: 'transport' },
+ },
+ {
+ context: { method: 'POST', path: '/api/v1/images', status: 503 },
+ level: 'debug',
+ message: 'POST /api/v1/images responded 503',
+ name: 'http.response-error',
+ },
+ ]);
+ });
+
+ it('drops breadcrumbs from requests whose account lifetime ended and ignores aborts', async () => {
+ accountLifecycle.activate('user-a');
+ let settle: (response: Response) => void = () => undefined;
+
+ vi.stubGlobal(
+ 'fetch',
+ vi
+ .fn()
+ .mockImplementationOnce(
+ () =>
+ new Promise<Response>((resolve) => {
+ settle = resolve;
+ })
+ )
+ .mockRejectedValueOnce(new DOMException('aborted', 'AbortError'))
+ );
+
+ const late = apiFetch('/api/v1/boards');
+
+ accountLifecycle.invalidate();
+ configureLogging({ ...DEFAULT_LOGGING_CONFIG, level: 'debug' });
+ settle(new Response('', { status: 500 }));
+ await expect(late).rejects.toBeInstanceOf(ApiError);
+ await expect(apiFetch('/api/v1/images')).rejects.toBeInstanceOf(DOMException);
+
+ expect(getLogSnapshot().entries).toEqual([]);
+ });
+
+ it('records nothing for successful requests', async () => {
+ vi.stubGlobal('fetch', vi.fn().mockResolvedValue(new Response('{}', { status: 200 })));
+
+ await apiFetch('/api/v1/app/version');
+
+ expect(getLogSnapshot().entries).toEqual([]);
+ });
+});
+
describe('media cookie credentials', () => {
beforeEach(() => {
// Keep the identity object stable; a fresh object would simulate rotation before the assertion.
diff --git a/invokeai/frontend/webv2/src/platform/transport/http.ts b/invokeai/frontend/webv2/src/platform/transport/http.ts
index 422fe487a6..5fb4bea17e 100644
--- a/invokeai/frontend/webv2/src/platform/transport/http.ts
+++ b/invokeai/frontend/webv2/src/platform/transport/http.ts
@@ -1,5 +1,8 @@
/** Read the Auth-owned bearer token per request so HTTP and WebSocket identity stay aligned without reloads. */
+import { recordLogEvent } from '@platform/logging/logger';
+import { captureAccountScope } from '@platform/state/accountLifecycle';
+
import { getDeploymentBasePath, getDeploymentBaseUrl } from './deploymentBase';
const API_BASE_URL = (import.meta.env.VITE_INVOKEAI_API_BASE_URL ?? '').trim().replace(/\/$/, '');
@@ -10,6 +13,9 @@ export interface HttpAuthAdapter {
onUnauthorized(rejectedToken: string, rejectedIdentity: unknown): void;
}
+/** Transport failures are breadcrumbs; the caller that handles the outcome owns the terminal report. */
+const HTTP_LOG_SOURCE = { area: 'http', namespace: 'transport' } as const;
+
let authAdapter: HttpAuthAdapter = {
getIdentity: () => null,
getToken: () => null,
@@ -134,8 +140,17 @@ export const assertOk = async (response: Response): Promise<Response> => {
throw new ApiError(text || `${response.status} ${response.statusText}`, response.status, response.headers);
};
-const fetchWithAuthToken = (path: string, init: RequestInit | undefined, token: string | null): Promise<Response> => {
+const fetchWithAuthToken = async (
+ path: string,
+ init: RequestInit | undefined,
+ token: string | null
+): Promise<Response> => {
const headers = new Headers(init?.headers);
+ const method = (init?.method ?? 'GET').toUpperCase();
+ // Breadcrumbs carry the path only; query strings can hold tokens and user input. They are fenced to the account
+ // that started the request so late settlements never land in the next account's history.
+ const safePath = path.split(/[?#]/, 1)[0] ?? path;
+ const owner = captureAccountScope();
if (token && !headers.has('Authorization')) {
headers.set('Authorization', `Bearer ${token}`);
@@ -143,7 +158,42 @@ const fetchWithAuthToken = (path: string, init: RequestInit | undefined, token:
// Use same-origin credentials so login stores the media cookie. Cross-origin API callers must opt into include
// and configure server credential support.
- return fetch(buildApiUrl(path), { credentials: 'same-origin', ...init, headers });
+ let response: Response;
+
+ try {
+ response = await fetch(buildApiUrl(path), { credentials: 'same-origin', ...init, headers });
+ } catch (error) {
+ // Aborts are expected cancellations (account cleanup, superseded queries), not failures.
+ if (!(error instanceof DOMException && error.name === 'AbortError')) {
+ recordLogEvent(
+ 'debug',
+ HTTP_LOG_SOURCE,
+ {
+ context: { method, path: safePath },
+ error,
+ message: `${method} ${safePath} failed`,
+ name: 'http.request-failed',
+ },
+ owner
+ );
+ }
+ throw error;
+ }
+
+ if (!response.ok) {
+ recordLogEvent(
+ 'debug',
+ HTTP_LOG_SOURCE,
+ {
+ context: { method, path: safePath, status: response.status },
+ message: `${method} ${safePath} responded ${response.status}`,
+ name: 'http.response-error',
+ },
+ owner
+ );
+ }
+
+ return response;
};
/** Authenticated fetch that leaves status handling to the caller. */
diff --git a/invokeai/frontend/webv2/src/platform/transport/socketHub.test.ts b/invokeai/frontend/webv2/src/platform/transport/socketHub.test.ts
index b136def252..3f66bccb06 100644
--- a/invokeai/frontend/webv2/src/platform/transport/socketHub.test.ts
+++ b/invokeai/frontend/webv2/src/platform/transport/socketHub.test.ts
@@ -1,3 +1,5 @@
+import { DEFAULT_LOGGING_CONFIG } from '@platform/logging/contracts';
+import { configureLogging, getLogSnapshot, resetLogging } from '@platform/logging/logger';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { BackendSocket } from './socketHub';
@@ -150,4 +152,30 @@ describe('socketHub', () => {
expect(getConnectionStatus().status).toBe('disconnected');
});
+
+ it('records connection transitions with disconnects as warnings', () => {
+ resetLogging();
+ configureLogging({ ...DEFAULT_LOGGING_CONFIG, level: 'debug' });
+ const socket = new FakeSocket();
+ const hub = createSocketHub({ createSocket: () => socket });
+
+ hub.connect();
+ socket.fire('disconnect', 'transport close');
+ socket.fire('connect_error', { message: 'xhr poll error' });
+ socket.fire('connect_error', { message: 'xhr poll error' });
+
+ expect(getLogSnapshot().entries).toMatchObject([
+ { level: 'debug', message: 'Backend socket reconnect failed: xhr poll error', name: 'socket.reconnect-failed' },
+ { level: 'warn', message: 'Backend socket disconnected: xhr poll error', name: 'socket.disconnected' },
+ {
+ context: { previous: 'connected', reason: 'transport close' },
+ level: 'warn',
+ message: 'Backend socket disconnected: transport close',
+ name: 'socket.disconnected',
+ source: { area: 'socket', namespace: 'transport' },
+ },
+ { level: 'info', name: 'socket.connected' },
+ { level: 'debug', name: 'socket.connecting' },
+ ]);
+ });
});
diff --git a/invokeai/frontend/webv2/src/platform/transport/socketHub.ts b/invokeai/frontend/webv2/src/platform/transport/socketHub.ts
index 2991e5045f..87812e7c0b 100644
--- a/invokeai/frontend/webv2/src/platform/transport/socketHub.ts
+++ b/invokeai/frontend/webv2/src/platform/transport/socketHub.ts
@@ -1,3 +1,4 @@
+import { createLogger } from '@platform/logging/logger';
import { io } from 'socket.io-client';
import type { BackendConnectionStatus } from './types';
@@ -41,6 +42,8 @@ const createDefaultSocket = (): BackendSocket => {
}) as unknown as BackendSocket;
};
+const socketLogger = createLogger({ area: 'socket', namespace: 'transport' });
+
export const createSocketHub = (options: { createSocket?: () => BackendSocket } = {}): SocketHub => {
const createSocket = options.createSocket ?? createDefaultSocket;
@@ -58,8 +61,25 @@ export const createSocketHub = (options: { createSocket?: () => BackendSocket }
const connectionListeners = new Set<ConnectionListener>();
const publishStatus = (next: BackendConnectionStatus, error?: string): void => {
+ const previous = status;
+ const previousError = lastError;
+
status = next;
lastError = error;
+ if (next === 'disconnected') {
+ // Reconnect attempts repeat the same failure; keep one warning per outage and the retries as breadcrumbs.
+ const isRepeat = previous === 'disconnected' && previousError === error;
+
+ socketLogger[isRepeat ? 'debug' : 'warn']({
+ context: { previous, reason: error },
+ message: `Backend socket ${isRepeat ? 'reconnect failed' : 'disconnected'}${error ? `: ${error}` : ''}`,
+ name: isRepeat ? 'socket.reconnect-failed' : 'socket.disconnected',
+ });
+ } else if (next === 'connected') {
+ socketLogger.info({ context: { previous }, message: 'Backend socket connected', name: 'socket.connected' });
+ } else {
+ socketLogger.debug({ context: { previous }, message: 'Backend socket connecting', name: 'socket.connecting' });
+ }
setConnectionStatus(next, error);
for (const listener of connectionListeners) {
diff --git a/invokeai/frontend/webv2/src/workbench/projects/useProjectFileActions.ts b/invokeai/frontend/webv2/src/workbench/projects/useProjectFileActions.ts
index 6b2047ead7..7ec77e8e14 100644
--- a/invokeai/frontend/webv2/src/workbench/projects/useProjectFileActions.ts
+++ b/invokeai/frontend/webv2/src/workbench/projects/useProjectFileActions.ts
@@ -1,6 +1,7 @@
import type { Project } from '@workbench/projectContracts';
import { fontKeys } from '@features/fonts/contracts';
+import { createLogger } from '@platform/logging/logger';
import {
assertAccountScopeCurrent,
captureAccountScope,
@@ -22,6 +23,8 @@ import { startProjectFileReport } from './projectFileToasts';
/** Share the scoped transfer and reporting lifecycle across callers. */
+const projectFileLogger = createLogger({ area: 'project-file', namespace: 'persistence' });
+
/** Runs the sequence, keeping the toast and the account scope in step. */
const runReported = async <T>(
t: (key: string, options?: Record<string, unknown>) => string,
@@ -33,6 +36,11 @@ const runReported = async <T>(
try {
await run(report, owner);
+ projectFileLogger.info({
+ context: { direction: titles.direction, operation: titles.running },
+ message: 'Project file operation completed',
+ name: 'persistence.project-file-completed',
+ });
} catch (error) {
// Account-cancellation errors stay silent because the operation no longer belongs to the active session.
if (!isAccountScopeCurrent(owner)) {
@@ -41,6 +49,12 @@ const runReported = async <T>(
return;
}
+ projectFileLogger.error({
+ context: { direction: titles.direction },
+ error,
+ message: titles.failed,
+ name: 'persistence.project-file-failed',
+ });
report.fail(titles.failed, error);
}
};
diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFailureBoundary.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFailureBoundary.tsx
index 9ed69391c1..8ce8fd814a 100644
--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFailureBoundary.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFailureBoundary.tsx
@@ -6,6 +6,7 @@ import type {
} from '@workbench/widgetContracts';
import { Box, Code, Flex, HStack, ScrollArea, Stack, Text, useRecipe } from '@chakra-ui/react';
+import { createLogger } from '@platform/logging/logger';
import { Button } from '@platform/ui/Button';
import { toaster } from '@platform/ui/toaster';
import { useScrollAreaPhantomHeal } from '@platform/ui/useScrollAreaPhantomHeal';
@@ -17,11 +18,15 @@ import { useTranslation } from 'react-i18next';
import { WidgetPanelFrame, WidgetTooltipFrame } from './WidgetFrames';
+const widgetFailureLogger = createLogger({ area: 'widget-render', namespace: 'system' });
+
interface WidgetFailureBoundaryProps {
children: ReactNode;
/** Retain region framing, size, and resize handles on failure; headless hosts omit presentation context. */
instance?: WidgetInstanceRuntimeMeta;
presentation?: WidgetViewProps['presentation'];
+ /** Attributes the failure to the project hosting the widget. */
+ projectId?: string;
region?: WidgetViewProps['region'];
resetKey: string;
widget?: RegisteredWidget;
@@ -234,6 +239,17 @@ export class WidgetFailureBoundary extends Component<WidgetFailureBoundaryProps,
}
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
+ widgetFailureLogger.child({ projectId: this.props.projectId }).error({
+ context: {
+ componentStack: errorInfo.componentStack,
+ instanceId: this.props.instance?.id,
+ region: this.props.region,
+ widgetId: this.props.widgetId,
+ },
+ error,
+ message: `Widget ${this.props.widgetId} failed to render`,
+ name: 'widget.render-failed',
+ });
this.setState({ details: errorInfo.componentStack ?? error.stack ?? error.message });
}
diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsx
index 707a0c23dc..73d2252c28 100644
--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsx
@@ -16,7 +16,7 @@ import { Scrollable } from '@platform/ui/Scrollable';
import { WidgetOverlayOwnerContext } from '@platform/ui/widgetOverlays';
import { WidgetSettingsButton } from '@workbench/settings/WidgetSettingsButton';
import { areWidgetPlacementProjectsEqual, getWidgetPlacementProject } from '@workbench/widgetPlacementMeta';
-import { useActiveProjectSelector } from '@workbench/WorkbenchContext';
+import { useActiveProjectId, useActiveProjectSelector } from '@workbench/WorkbenchContext';
import { useWorkbenchWidgetRegistry } from '@workbench/WorkbenchWidgetRegistryContext';
import { memo, Suspense, use, useMemo } from 'react';
@@ -158,6 +158,7 @@ const WidgetChromeSlot = ({
};
export const WidgetRenderer = ({ instance, presentation, region, widget }: WidgetRendererProps) => {
+ const projectId = useActiveProjectId();
const loadingFallback = useMemo(
() => <WidgetLoadingFallback instance={instance} presentation={presentation} region={region} widget={widget} />,
[instance, presentation, region, widget]
@@ -176,6 +177,7 @@ export const WidgetRenderer = ({ instance, presentation, region, widget }: Widge
<WidgetFailureBoundary
instance={instance}
presentation={presentation}
+ projectId={projectId}
region={region}
resetKey={instance.id}
widget={widget}