diff --git a/test/napi/napi-app/module.js b/test/napi/napi-app/module.js index 47674e1d06..33e7fbbdd9 100644 --- a/test/napi/napi-app/module.js +++ b/test/napi/napi-app/module.js @@ -619,21 +619,12 @@ nativeTests.test_get_value_string = () => { } }; -nativeTests.test_worker_throw_with_finalizer = () => { - const { promise, resolve, reject } = Promise.withResolvers(); - const worker = new Worker( - /* js */ ` - import { createRequire } from "node:module"; - const require = createRequire(import.meta.url); - const { add_finalizer_to_object } = require("./build/Debug/napitests.node"); - let object = {}; - add_finalizer_to_object(object); - `, - { eval: true }, - ); - worker.on("exit", resolve); - worker.on("error", reject); - return promise; +// Should be run with +// BUN_DESTRUCT_VM_ON_EXIT=1 -- makes us tear down the JSC::VM while exiting, so that finalizers run +// BUN_JSC_useGC=0 -- ensures the object's finalizer will be called at exit not during normal GC +nativeTests.test_finalizer_called_during_destruction = () => { + let object = {}; + nativeTests.add_finalizer_to_object(object); }; module.exports = nativeTests; diff --git a/test/napi/napi.test.ts b/test/napi/napi.test.ts index 701e525691..7ef676acf9 100644 --- a/test/napi/napi.test.ts +++ b/test/napi/napi.test.ts @@ -1,6 +1,6 @@ import { spawnSync } from "bun"; import { beforeAll, describe, expect, it } from "bun:test"; -import { bunEnv, bunExe, tempDirWithFiles } from "harness"; +import { bunEnv, bunExe, isBroken, tempDirWithFiles } from "harness"; import { join } from "path"; describe("napi", () => { @@ -455,8 +455,9 @@ describe("napi", () => { }); describe("napi_add_finalizer", () => { - it("does not crash if the finalizer is called during VM shutdown", () => { - checkSameOutput("test_worker_throw_with_finalizer", [], { + it.todoIf(isBroken)("does not crash if the finalizer is called during VM shutdown", () => { + checkSameOutput("test_finalizer_called_during_destruction", [], { + BUN_DESTRUCT_VM_ON_EXIT: "1", BUN_JSC_useGC: "0", }); });