Skip to content

Commit 20790b1

Browse files
committed
fix notif error + sync manifest undefined exit
1 parent e87c280 commit 20790b1

6 files changed

Lines changed: 95 additions & 3 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/utils/workflow-execution-utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ export function createBlockEventHandlers(
302302
updateConsole(
303303
data.blockId,
304304
{
305+
blockName: data.blockName,
306+
blockType: data.blockType,
305307
executionOrder: data.executionOrder,
306308
input: data.input || {},
307309
replaceOutput: data.output,
@@ -320,6 +322,8 @@ export function createBlockEventHandlers(
320322
updateConsole(
321323
data.blockId,
322324
{
325+
blockName: data.blockName,
326+
blockType: data.blockType,
323327
executionOrder: data.executionOrder,
324328
input: data.input || {},
325329
replaceOutput: {},
@@ -493,6 +497,8 @@ export function reconcileFinalBlockLogs(
493497
log.blockId,
494498
{
495499
executionOrder: log.executionOrder,
500+
blockName: log.blockName,
501+
blockType: log.blockType,
496502
replaceOutput: (log.output ?? {}) as Record<string, unknown>,
497503
...(log.input ? { input: log.input } : {}),
498504
success: log.success,
@@ -576,6 +582,8 @@ function spanConsoleIdentity(span: TraceSpan, childWorkflowInstanceId: string):
576582
const iterationContainerId = span.loopId ?? span.parallelId
577583
const iterationType = span.loopId ? 'loop' : span.parallelId ? 'parallel' : undefined
578584
return {
585+
blockName: span.name,
586+
blockType: span.type,
579587
...(span.executionOrder !== undefined && { executionOrder: span.executionOrder }),
580588
...(span.iterationIndex !== undefined && { iterationCurrent: span.iterationIndex }),
581589
...(iterationType !== undefined && { iterationType }),

apps/sim/executor/variables/resolvers/reference.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,38 @@ describe('navigatePath', () => {
176176
})
177177
})
178178

179+
describe('large array manifests', () => {
180+
it('returns undefined for sync index access when the chunk is not cached', () => {
181+
const manifest = {
182+
__simLargeArrayManifest: true,
183+
version: 2,
184+
kind: 'array',
185+
totalCount: 1,
186+
chunkCount: 1,
187+
byteSize: 16,
188+
chunks: [
189+
{
190+
ref: {
191+
__simLargeValueRef: true,
192+
version: 1,
193+
id: 'lv_ABCDEFGHIJKL',
194+
kind: 'array',
195+
size: 16,
196+
executionId: 'execution-1',
197+
},
198+
count: 1,
199+
byteSize: 16,
200+
},
201+
],
202+
preview: [{ id: 1 }],
203+
}
204+
205+
expect(navigatePath(manifest, ['0'])).toBeUndefined()
206+
expect(navigatePath(manifest, ['length'])).toBe(1)
207+
expect(navigatePath(manifest, ['preview'])).toEqual([{ id: 1 }])
208+
})
209+
})
210+
179211
describe('bracket notation edge cases', () => {
180212
it.concurrent('should handle bracket notation with property access', () => {
181213
const obj = { data: [{ value: 100 }, { value: 200 }] }

apps/sim/executor/variables/resolvers/reference.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { materializeLargeValueRefSyncOrThrow } from '@/lib/execution/payloads/cache'
1+
import {
2+
materializeLargeValueRefSync,
3+
materializeLargeValueRefSyncOrThrow,
4+
} from '@/lib/execution/payloads/cache'
25
import {
36
isLargeArrayManifest,
47
type LargeArrayManifest,
@@ -79,7 +82,10 @@ function readManifestIndexSync(
7982
for (const chunk of manifest.chunks) {
8083
const nextOffset = offset + chunk.count
8184
if (index < nextOffset) {
82-
const materialized = materializeLargeValueRefSyncOrThrow(chunk.ref, executionContext)
85+
const materialized = materializeLargeValueRefSync(chunk.ref, executionContext)
86+
if (materialized === undefined) {
87+
return undefined
88+
}
8389
if (!Array.isArray(materialized)) {
8490
throw new Error('Large array manifest chunk must materialize to an array.')
8591
}

apps/sim/stores/terminal/console/store.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
55

66
vi.unmock('@/stores/terminal')
77
vi.unmock('@/stores/terminal/console/store')
8+
vi.unmock('@/stores/notifications')
89

10+
import { useNotificationStore } from '@/stores/notifications'
911
import { useTerminalConsoleStore } from '@/stores/terminal/console/store'
1012

1113
describe('terminal console store', () => {
@@ -17,6 +19,9 @@ describe('terminal console store', () => {
1719
isOpen: false,
1820
_hasHydrated: true,
1921
})
22+
useNotificationStore.setState({
23+
notifications: [],
24+
})
2025
})
2126

2227
it('normalizes oversized payloads when adding console entries', () => {
@@ -117,6 +122,37 @@ describe('terminal console store', () => {
117122
expect(after.getWorkflowEntries('wf-1')[0].output).toMatchObject({ status: 'updated' })
118123
})
119124

125+
it('uses the block name from error updates in notifications', () => {
126+
useTerminalConsoleStore.getState().addConsole({
127+
workflowId: 'wf-1',
128+
blockId: 'block-1',
129+
blockName: 'Unknown Block',
130+
blockType: 'function',
131+
executionId: 'exec-1',
132+
executionOrder: 1,
133+
isRunning: true,
134+
})
135+
136+
useTerminalConsoleStore.getState().updateConsole(
137+
'block-1',
138+
{
139+
blockName: 'Transform Data',
140+
blockType: 'function',
141+
executionOrder: 1,
142+
error: 'Boom',
143+
success: false,
144+
},
145+
'exec-1'
146+
)
147+
148+
const [entry] = useTerminalConsoleStore.getState().getWorkflowEntries('wf-1')
149+
const [notification] = useNotificationStore.getState().notifications
150+
151+
expect(entry.blockName).toBe('Transform Data')
152+
expect(notification.message).toBe('Transform Data: Boom')
153+
expect(notification.action?.message).toContain('Error in Transform Data.')
154+
})
155+
120156
describe('cancelRunningEntries', () => {
121157
it('flips a plain running entry to canceled', () => {
122158
useTerminalConsoleStore.getState().addConsole({

apps/sim/stores/terminal/console/store.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,14 @@ export const useTerminalConsoleStore = create<ConsoleStore>()(
507507
: normalizeConsoleOutput(mergedOutput)
508508
}
509509

510+
if (update.blockName !== undefined) {
511+
updatedEntry.blockName = update.blockName
512+
}
513+
514+
if (update.blockType !== undefined) {
515+
updatedEntry.blockType = update.blockType
516+
}
517+
510518
if (update.error !== undefined) {
511519
updatedEntry.error = normalizeConsoleError(update.error)
512520
}
@@ -605,7 +613,7 @@ export const useTerminalConsoleStore = create<ConsoleStore>()(
605613
.find((entry) => matchesEntryForUpdate(entry, blockId, executionId, update))
606614
notifyBlockError({
607615
error: update.error,
608-
blockName: matchingEntry?.blockName || 'Unknown Block',
616+
blockName: update.blockName || matchingEntry?.blockName || 'Unknown Block',
609617
workflowId: matchingEntry?.workflowId,
610618
logContext: { blockId },
611619
})

apps/sim/stores/terminal/console/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export interface ConsoleUpdate {
3838
content?: string
3939
output?: Partial<NormalizedBlockOutput>
4040
replaceOutput?: NormalizedBlockOutput
41+
blockName?: string
42+
blockType?: string
4143
executionOrder?: number
4244
error?: string | Error | null
4345
warning?: string

0 commit comments

Comments
 (0)