Skip to content

Commit 24d16ef

Browse files
committed
fix: BP evaluation add process and return error if failing runInContext
1 parent af14bcd commit 24d16ef

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

meteor/server/api/blueprints/cache.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@ import { stringifyError } from '@sofie-automation/shared-lib/dist/lib/stringifyE
66

77
export function evalBlueprint(blueprint: Pick<Blueprint, '_id' | 'name' | 'code'>): SomeBlueprintManifest {
88
const blueprintPath = `db:///blueprint/${blueprint.name || blueprint._id}-bundle.js`
9-
const context = vm.createContext({}, {})
9+
const context = vm.createContext({ process: process }, {})
1010
const script = new vm.Script(
1111
`__run_result = ${blueprint.code}
1212
__run_result || blueprint`,
1313
{
1414
filename: blueprintPath,
1515
}
1616
)
17-
const entry = script.runInContext(context)
17+
18+
let entry: any
19+
try {
20+
entry = script.runInContext(context)
21+
} catch (e) {
22+
console.error(`Error evaluating Blueprint .runInContext "${blueprint._id}": "${stringifyError(e)}"`)
23+
}
1824

1925
const manifest: SomeBlueprintManifest = entry.default
2026

0 commit comments

Comments
 (0)