Skip to content

Commit

Permalink
feat(engine): ⚡️ Await for async code block
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Mar 25, 2022
1 parent fb60dcf commit d756dff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/bot-engine/src/services/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const executeLogic = async (
case LogicStepType.REDIRECT:
return { nextEdgeId: executeRedirect(step, context) }
case LogicStepType.CODE:
return { nextEdgeId: executeCode(step, context) }
return { nextEdgeId: await executeCode(step, context) }
case LogicStepType.TYPEBOT_LINK:
return await executeTypebotLink(step, context)
}
Expand Down Expand Up @@ -121,12 +121,12 @@ const executeRedirect = (
return step.outgoingEdgeId
}

const executeCode = (
const executeCode = async (
step: CodeStep,
{ typebot: { variables } }: LogicContext
) => {
if (!step.options.content) return
Function(parseVariables(variables)(step.options.content))()
await Function(parseVariables(variables)(step.options.content))()
return step.outgoingEdgeId
}

Expand Down

2 comments on commit d756dff

@vercel
Copy link

@vercel vercel bot commented on d756dff Mar 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.