Skip to content

Commit 0b9db4d

Browse files
committed
fix(condition): async execution isolated vm error
1 parent 7ef1150 commit 0b9db4d

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

apps/sim/executor/handlers/condition/condition-handler.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { generateRequestId } from '@/lib/core/utils/request'
2-
import { executeInIsolatedVM } from '@/lib/execution/isolated-vm'
31
import { createLogger } from '@/lib/logs/console/logger'
42
import type { BlockOutput } from '@/blocks/types'
53
import { BlockType, CONDITION, DEFAULTS, EDGE } from '@/executor/constants'
64
import type { BlockHandler, ExecutionContext } from '@/executor/types'
75
import type { SerializedBlock } from '@/serializer/types'
6+
import { executeTool } from '@/tools'
87

98
const logger = createLogger('ConditionBlockHandler')
109

@@ -39,32 +38,37 @@ export async function evaluateConditionExpression(
3938
}
4039

4140
try {
42-
const requestId = generateRequestId()
43-
4441
const code = `return Boolean(${resolvedConditionValue})`
4542

46-
const result = await executeInIsolatedVM({
47-
code,
48-
params: {},
49-
envVars: {},
50-
contextVariables: { context: evalContext },
51-
timeoutMs: CONDITION_TIMEOUT_MS,
52-
requestId,
53-
})
43+
const result = await executeTool(
44+
'function_execute',
45+
{
46+
code,
47+
timeout: CONDITION_TIMEOUT_MS,
48+
envVars: {},
49+
_context: {
50+
workflowId: ctx.workflowId,
51+
workspaceId: ctx.workspaceId,
52+
},
53+
},
54+
false,
55+
false,
56+
ctx
57+
)
5458

55-
if (result.error) {
56-
logger.error(`Failed to evaluate condition: ${result.error.message}`, {
59+
if (!result.success) {
60+
logger.error(`Failed to evaluate condition: ${result.error}`, {
5761
originalCondition: conditionExpression,
5862
resolvedCondition: resolvedConditionValue,
5963
evalContext,
6064
error: result.error,
6165
})
6266
throw new Error(
63-
`Evaluation error in condition: ${result.error.message}. (Resolved: ${resolvedConditionValue})`
67+
`Evaluation error in condition: ${result.error}. (Resolved: ${resolvedConditionValue})`
6468
)
6569
}
6670

67-
return Boolean(result.result)
71+
return Boolean(result.output?.result)
6872
} catch (evalError: any) {
6973
logger.error(`Failed to evaluate condition: ${evalError.message}`, {
7074
originalCondition: conditionExpression,

0 commit comments

Comments
 (0)