Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions browser_tests/fixtures/agentFollowerHostSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -86,11 +87,11 @@ function docFrameEnvelope(
raw: string | Buffer
): { type: string; data: Record<string, unknown> } | 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<string, unknown> }
if (!isPlainObject(data)) return null
return { type, data }
}

function stringOrNull(value: unknown): string | null {
Expand Down
5 changes: 3 additions & 2 deletions browser_tests/fixtures/agentWireFrame.ts
Original file line number Diff line number Diff line change
@@ -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]

Expand All @@ -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) &&
Expand Down
Loading