diff --git a/browser_tests/fixtures/agentFollowerHostSocket.ts b/browser_tests/fixtures/agentFollowerHostSocket.ts index 86342b4a121..48fdb508696 100644 --- a/browser_tests/fixtures/agentFollowerHostSocket.ts +++ b/browser_tests/fixtures/agentFollowerHostSocket.ts @@ -27,6 +27,7 @@ import type { ParsedWireBatch, WireOpEnvelope } from '@e2e/fixtures/agentWireFrame' +import { isPlainObject } from 'es-toolkit' const SUBSCRIBE_TIMEOUT = 15_000 /** The sid the fake ComfyUI reports on its first `status` frame. */ @@ -86,11 +87,11 @@ function docFrameEnvelope( raw: string | Buffer ): { type: string; data: Record } | null { const frame: unknown = JSON.parse(raw.toString()) - if (typeof frame !== 'object' || frame === null) return null - const { type, data } = frame as { type?: unknown; data?: unknown } + if (!isPlainObject(frame)) return null + const { type, data } = frame if (typeof type !== 'string' || !type.startsWith('doc_')) return null - if (typeof data !== 'object' || data === null) return null - return { type, data: data as Record } + if (!isPlainObject(data)) return null + return { type, data } } function stringOrNull(value: unknown): string | null { diff --git a/browser_tests/fixtures/agentWireFrame.ts b/browser_tests/fixtures/agentWireFrame.ts index 569a8659dc5..3b01167791e 100644 --- a/browser_tests/fixtures/agentWireFrame.ts +++ b/browser_tests/fixtures/agentWireFrame.ts @@ -1,4 +1,5 @@ import { DEFERRED_OPS, FROZEN_OPS } from '@comfyorg/comfy-multi-player' +import { isPlainObject } from 'es-toolkit' const WIRE_OP_KINDS: readonly string[] = [...FROZEN_OPS, ...DEFERRED_OPS] @@ -16,8 +17,8 @@ export interface WireOpEnvelope { } function isWireEnvelopeShaped(value: unknown): value is WireOpEnvelope { - if (typeof value !== 'object' || value === null) return false - const { op, op_id } = value as { op?: unknown; op_id?: unknown } + if (!isPlainObject(value)) return false + const { op, op_id } = value return ( typeof op === 'string' && WIRE_OP_KINDS.includes(op) &&