From 1c39693b5a3de6f682b15a06a62d935d1ff93731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 26 May 2023 08:42:23 +0200 Subject: [PATCH 1/2] fix(node): make 'v8.setFlagsFromString' a noop --- cli/tests/unit_node/v8_test.ts | 4 ++-- ext/node/polyfills/v8.ts | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cli/tests/unit_node/v8_test.ts b/cli/tests/unit_node/v8_test.ts index ab19035962d47a..3570c32f162144 100644 --- a/cli/tests/unit_node/v8_test.ts +++ b/cli/tests/unit_node/v8_test.ts @@ -51,8 +51,8 @@ Deno.test({ }); Deno.test({ - name: "setFlagsFromString throws", + name: "setFlagsFromString", fn() { - assertThrows(() => setFlagsFromString("--allow_natives_syntax")); + setFlagsFromString("--allow_natives_syntax"); }, }); diff --git a/ext/node/polyfills/v8.ts b/ext/node/polyfills/v8.ts index 27feb1cecb2366..e411b541e0bbf4 100644 --- a/ext/node/polyfills/v8.ts +++ b/ext/node/polyfills/v8.ts @@ -42,7 +42,14 @@ export function getHeapStatistics() { } export function setFlagsFromString() { - notImplemented("v8.setFlagsFromString"); + // NOTE(bartlomieju): From Node.js docs: + // The v8.setFlagsFromString() method can be used to programmatically set V8 + // command-line flags. This method should be used with care. Changing settings + // after the VM has started may result in unpredictable behavior, including + // crashes and data loss; or it may simply do nothing. + // + // Notice: "or it may simply do nothing". This is what we're gonna do, + // this function will just be a no-op. } export function stopCoverage() { notImplemented("v8.stopCoverage"); From 7aeb1b58443b81bce0433193da0493513c01289d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 26 May 2023 08:55:37 +0200 Subject: [PATCH 2/2] lint --- cli/tests/unit_node/v8_test.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cli/tests/unit_node/v8_test.ts b/cli/tests/unit_node/v8_test.ts index 3570c32f162144..724ac35044db0e 100644 --- a/cli/tests/unit_node/v8_test.ts +++ b/cli/tests/unit_node/v8_test.ts @@ -4,10 +4,7 @@ import { getHeapStatistics, setFlagsFromString, } from "node:v8"; -import { - assertEquals, - assertThrows, -} from "../../../test_util/std/testing/asserts.ts"; +import { assertEquals } from "../../../test_util/std/testing/asserts.ts"; // https://github.com/nodejs/node/blob/a2bbe5ff216bc28f8dac1c36a8750025a93c3827/test/parallel/test-v8-version-tag.js#L6 Deno.test({