🐛 (script) Fix script exec when one variable is object
This commit is contained in:
@ -47,7 +47,7 @@ export const createHttpReqResponseMappingRunner = (response: any) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const parseTransferrableValue = (value: unknown) => {
|
export const parseTransferrableValue = (value: unknown) => {
|
||||||
if (typeof value === 'object') {
|
if (typeof value === 'object') {
|
||||||
return new ivm.ExternalCopy(value).copyInto()
|
return new ivm.ExternalCopy(value).copyInto()
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import { isDefined } from '@typebot.io/lib'
|
|||||||
import { safeStringify } from '@typebot.io/lib/safeStringify'
|
import { safeStringify } from '@typebot.io/lib/safeStringify'
|
||||||
import { Variable } from './types'
|
import { Variable } from './types'
|
||||||
import ivm from 'isolated-vm'
|
import ivm from 'isolated-vm'
|
||||||
|
import { parseTransferrableValue } from './codeRunners'
|
||||||
|
|
||||||
const defaultTimeout = 10 * 1000
|
const defaultTimeout = 10 * 1000
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ export const executeFunction = async ({
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
args.forEach(({ id, value }) => {
|
args.forEach(({ id, value }) => {
|
||||||
jail.setSync(id, value)
|
jail.setSync(id, parseTransferrableValue(value))
|
||||||
})
|
})
|
||||||
const run = (code: string) =>
|
const run = (code: string) =>
|
||||||
context.evalClosure(
|
context.evalClosure(
|
||||||
|
Reference in New Issue
Block a user