Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/execute-script-v2' into execute-…
Browse files Browse the repository at this point in the history
…script-v2-frontend
  • Loading branch information
deanhannigan committed Feb 3, 2025
2 parents a280039 + 37a544e commit f1fb9a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/server/src/jsRunner/tests/isolatedVM.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,15 @@ describe("Test isolated vm directly", () => {
)
expect(result).toEqual([])
})

it("should ensure error results are cleared between runs", () => {
const context = {}
// throw error
// Ensure the first execution throws an error
expect(() => runJSWithIsolatedVM(`test.foo.bar = 123`, context)).toThrow()

// Ensure the error is not persisted across VMs
const secondResult = runJSWithIsolatedVM(`return {}`, context)
expect(secondResult).toEqual({})
})
})
1 change: 1 addition & 0 deletions packages/server/src/jsRunner/vm/isolated-vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export class IsolatedVM implements VM {

code = `
try {
results = {}
results['${this.runResultKey}']=${this.codeWrapper(code)}
} catch (e) {
results['${this.runErrorKey}']=e
Expand Down

0 comments on commit f1fb9a8

Please sign in to comment.