2
0

🐛 (script) Fix script exec when one variable is object

This commit is contained in:
Baptiste Arnaud
2024-05-27 15:07:12 +02:00
parent a17781dfa6
commit 85bcb699f8
2 changed files with 3 additions and 2 deletions

View File

@ -47,7 +47,7 @@ export const createHttpReqResponseMappingRunner = (response: any) => {
}
}
const parseTransferrableValue = (value: unknown) => {
export const parseTransferrableValue = (value: unknown) => {
if (typeof value === 'object') {
return new ivm.ExternalCopy(value).copyInto()
}

View File

@ -5,6 +5,7 @@ import { isDefined } from '@typebot.io/lib'
import { safeStringify } from '@typebot.io/lib/safeStringify'
import { Variable } from './types'
import ivm from 'isolated-vm'
import { parseTransferrableValue } from './codeRunners'
const defaultTimeout = 10 * 1000
@ -59,7 +60,7 @@ export const executeFunction = async ({
]
)
args.forEach(({ id, value }) => {
jail.setSync(id, value)
jail.setSync(id, parseTransferrableValue(value))
})
const run = (code: string) =>
context.evalClosure(