Skip to content

Commit a5e8a30

Browse files
waleedlatif1claude
andcommitted
fix(execution): type event buffer with ExecutionEvent instead of Record<string, unknown>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fde8f97 commit a5e8a30

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

apps/sim/app/api/workflows/[id]/execute/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
720720
}
721721
}
722722
if (event.type !== 'stream:chunk' && event.type !== 'stream:done') {
723-
eventWriter.write(event as unknown as Record<string, unknown>).catch(() => {})
723+
eventWriter.write(event).catch(() => {})
724724
}
725725
}
726726

apps/sim/app/api/workflows/[id]/executions/[executionId]/stream/route.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
getExecutionMeta,
88
readExecutionEvents,
99
} from '@/lib/execution/event-buffer'
10-
import { type ExecutionEvent, formatSSEEvent } from '@/lib/workflows/executor/execution-events'
10+
import { formatSSEEvent } from '@/lib/workflows/executor/execution-events'
1111
import { authorizeWorkflowByWorkspacePermission } from '@/lib/workflows/utils'
1212

1313
const logger = createLogger('ExecutionStreamReconnectAPI')
@@ -88,7 +88,7 @@ export async function GET(
8888
const events = await readExecutionEvents(executionId, lastEventId)
8989
for (const entry of events) {
9090
if (closed) return
91-
enqueue(formatSSEEvent(entry.event as unknown as ExecutionEvent))
91+
enqueue(formatSSEEvent(entry.event))
9292
lastEventId = entry.eventId
9393
}
9494

@@ -108,7 +108,7 @@ export async function GET(
108108
const newEvents = await readExecutionEvents(executionId, lastEventId)
109109
for (const entry of newEvents) {
110110
if (closed) return
111-
enqueue(formatSSEEvent(entry.event as unknown as ExecutionEvent))
111+
enqueue(formatSSEEvent(entry.event))
112112
lastEventId = entry.eventId
113113
}
114114

@@ -118,7 +118,7 @@ export async function GET(
118118
const finalEvents = await readExecutionEvents(executionId, lastEventId)
119119
for (const entry of finalEvents) {
120120
if (closed) return
121-
enqueue(formatSSEEvent(entry.event as unknown as ExecutionEvent))
121+
enqueue(formatSSEEvent(entry.event))
122122
lastEventId = entry.eventId
123123
}
124124
enqueue('data: [DONE]\n\n')

apps/sim/lib/execution/event-buffer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createLogger } from '@sim/logger'
22
import { getRedisClient } from '@/lib/core/config/redis'
3+
import type { ExecutionEvent } from '@/lib/workflows/executor/execution-events'
34

45
const logger = createLogger('ExecutionEventBuffer')
56

@@ -34,11 +35,11 @@ export interface ExecutionStreamMeta {
3435
export interface ExecutionEventEntry {
3536
eventId: number
3637
executionId: string
37-
event: Record<string, unknown>
38+
event: ExecutionEvent
3839
}
3940

4041
export interface ExecutionEventWriter {
41-
write: (event: Record<string, unknown>) => Promise<ExecutionEventEntry>
42+
write: (event: ExecutionEvent) => Promise<ExecutionEventEntry>
4243
flush: () => Promise<void>
4344
close: () => Promise<void>
4445
}
@@ -199,7 +200,7 @@ export function createExecutionEventWriter(executionId: string): ExecutionEventW
199200
}
200201
}
201202

202-
const write = async (event: Record<string, unknown>) => {
203+
const write = async (event: ExecutionEvent) => {
203204
if (closed) return { eventId: 0, executionId, event }
204205
if (nextEventId === 0 || nextEventId > maxReservedId) {
205206
await reserveIds(1)

0 commit comments

Comments
 (0)