From 1d290ccc2a39d355aa0e43e86f5f4ce09a0bd655 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Wed, 12 Jun 2024 22:32:54 +0530 Subject: fix(ext/node): fix vm memory usage and context initialization (#23976) Fixes https://github.com/denoland/deno/issues/22441 Fixes https://github.com/denoland/deno/issues/23913 Fixes https://github.com/denoland/deno/issues/23852 Fixes https://github.com/denoland/deno/issues/23917 --- tests/unit_node/vm_test.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/unit_node') diff --git a/tests/unit_node/vm_test.ts b/tests/unit_node/vm_test.ts index 21e56ee94..46e231c6c 100644 --- a/tests/unit_node/vm_test.ts +++ b/tests/unit_node/vm_test.ts @@ -148,3 +148,34 @@ reject().catch(() => {}) script.runInNewContext(); }, }); + +// https://github.com/denoland/deno/issues/22441 +Deno.test({ + name: "vm runInNewContext module loader", + fn() { + const code = "import('node:process')"; + const script = new Script(code); + script.runInNewContext(); + }, +}); + +// https://github.com/denoland/deno/issues/23913 +Deno.test({ + name: "vm memory leak crash", + fn() { + const script = new Script("returnValue = 2+2"); + + for (let i = 0; i < 1000; i++) { + script.runInNewContext({}, { timeout: 10000 }); + } + }, +}); + +// https://github.com/denoland/deno/issues/23852 +Deno.test({ + name: "vm runInThisContext global.foo", + fn() { + const result = runInThisContext(`global.foo = 1`); + assertEquals(result, 1); + }, +}); -- cgit v1.2.3