Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start fixing bugs discovered by Node.js's Node-API tests #14501

Draft
wants to merge 200 commits into
base: main
Choose a base branch
from

Conversation

190n
Copy link
Contributor

@190n 190n commented Oct 12, 2024

What does this PR do?

TODO before merging:

  • Get these tests running in CI
  • get other new tests to run from napi.test.ts
  • fix leak test
  • remove dependency on JSC change for napi_get_property_names (@heimskr) merged JSC change instead

Fixes #14336
Fixes #15383

Tests in js-native-api

  • 2_function_arguments/test.js
  • 3_callbacks/test.js
  • 4_object_factory/test.js
  • 5_function_factory/test.js
  • 6_object_wrap/test-object-wrap-ref.js
  • 6_object_wrap/test.js
  • 7_factory_wrap/test.js
  • 8_passing_wrapped/test.js
  • test_array/test.js
  • test_bigint/test.js
  • test_cannot_run_js/test.js
  • test_constructor/test.js
  • test_constructor/test2.js
  • test_constructor/test_null.js
  • test_conversions/test.js
  • test_dataview/test.js
  • test_date/test.js
  • test_error/test.js
  • test_exception/test.js
  • test_exception/testFinalizerException.js
  • test_finalizer/test.js
  • test_finalizer/test_fatal_finalize.js
  • test_function/test.js
  • test_general/test.js
  • test_general/testEnvCleanup.js
  • test_general/testFinalizer.js
  • test_general/testGlobals.js
  • test_general/testInstanceOf.js
  • test_general/testNapiRun.js
  • test_general/testNapiStatus.js
  • test_handle_scope/test.js
  • test_instance_data/test.js
  • test_new_target/test.js
  • test_number/test.js
  • test_number/test_null.js
  • test_object/test.js
  • test_object/test_exceptions.js
  • test_object/test_null.js
  • test_promise/test.js
  • test_properties/test.js
  • test_reference/test.js
  • test_reference/test_finalizer.js
  • test_reference_double_free/test.js
  • test_reference_double_free/test_wrap.js
  • test_string/test.js
  • test_string/test_null.js
  • test_symbol/test1.js
  • test_symbol/test2.js
  • test_symbol/test3.js
  • test_typedarray/test.js

How did you verify your code works?

Running Node's tests

@robobun
Copy link

robobun commented Oct 12, 2024

@heimskr, your commit 7886182 has 9 failures in #6737:

  • Failed to create agent for 🐧 x64-musl-baseline - build-bun
  • InvalidParameterValueWhen specifying CpuOptions you must specify both CoreCount and ThreadsPerCore.9929dcfc-2a3f-4642-b4a8-73bae6a59f5c
  • Failed to create agent for 🐧 aarch64-musl - build-bun
  • InvalidParameterValueWhen specifying CpuOptions you must specify both CoreCount and ThreadsPerCore.69485b2b-c2f8-43bb-8743-b4cab688018f
  • Failed to create agent for 🐧 x64-musl - build-bun
  • InvalidParameterValueWhen specifying CpuOptions you must specify both CoreCount and ThreadsPerCore.36504b2b-c592-4024-abec-7ad561646637
  • test/js/web/fetch/fetch.tls.test.ts - 1 failing on 🍎 13 aarch64
  • test/js/web/fetch/fetch.stream.test.ts - 1 failing on 🍎 13 aarch64
  • test/js/bun/spawn/spawn-stdin-destroy.test.ts - 1 failing on 🪟 2019 x64-baseline
  • test/js/third_party/prisma/prisma.test.ts - segmentation fault on 🪟 2019 x64
  • test/js/third_party/prisma/prisma.test.ts - segmentation fault on 🪟 2019 x64-baseline
  • test/js/third_party/prisma/prisma.test.ts - 1 failing on 🐧 20.04 x64
  • test/js/third_party/prisma/prisma.test.ts - 1 failing on 🐧 12 x64
  • test/js/third_party/prisma/prisma.test.ts - 1 failing on 🐧 22.04 x64
  • test/js/third_party/prisma/prisma.test.ts - 1 failing on 🐧 20.04 aarch64
  • test/js/third_party/prisma/prisma.test.ts - 1 failing on 🐧 12 aarch64
  • test/js/third_party/prisma/prisma.test.ts - 1 failing on 🐧 12 x64-baseline
  • test/js/third_party/prisma/prisma.test.ts - 1 failing on 🐧 22.04 aarch64
  • test/js/third_party/prisma/prisma.test.ts - 1 failing on 🐧 20.04 x64-baseline
  • test/js/third_party/prisma/prisma.test.ts - 1 failing on 🐧 22.04 x64-baseline
  • test/js/bun/http/serve.test.ts - 1 failing on 🍎 13 aarch64
  • test/js/bun/http/serve.test.ts - 1 failing on 🍎 14 x64
  • test/js/third_party/pg/pg.test.ts - 1 failing on 🪟 2019 x64
  • test/js/third_party/pg/pg.test.ts - 1 failing on 🪟 2019 x64-baseline
  • test/js/third_party/pg/pg.test.ts - 1 failing on 🐧 22.04 x64
  • test/js/third_party/pg/pg.test.ts - 1 failing on 🐧 12 x64
  • test/js/third_party/pg/pg.test.ts - 1 failing on 🐧 20.04 x64
  • test/js/third_party/pg/pg.test.ts - 1 failing on 🍎 14 aarch64
  • test/js/third_party/pg/pg.test.ts - 1 failing on 🍎 13 aarch64
  • test/js/third_party/pg/pg.test.ts - 1 failing on 🐧 12 aarch64
  • test/js/third_party/pg/pg.test.ts - 1 failing on 🐧 22.04 aarch64
  • test/js/third_party/pg/pg.test.ts - 1 failing on 🐧 20.04 aarch64
  • test/js/third_party/pg/pg.test.ts - 1 failing on 🐧 12 x64-baseline
  • test/js/third_party/pg/pg.test.ts - 1 failing on 🐧 22.04 x64-baseline
  • test/js/third_party/pg/pg.test.ts - 1 failing on 🐧 20.04 x64-baseline
  • test/js/third_party/pg/pg.test.ts - 1 failing on 🍎 14 x64
  • test/js/third_party/pg/pg.test.ts - 1 failing on 🍎 13 x64
  • test/cli/run/require-cache.test.ts - 1 failing on 🪟 2019 x64
  • test/cli/run/require-cache.test.ts - 1 failing on 🪟 2019 x64-baseline
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🍎 14 aarch64
  • @190n 190n changed the title Fix bugs discovered by Node.js's Node-API tests Start fixing bugs discovered by Node.js's Node-API tests Oct 16, 2024
    @190n 190n marked this pull request as ready for review October 16, 2024 20:55
    @190n 190n marked this pull request as draft October 17, 2024 16:29
    heimskr and others added 28 commits November 15, 2024 20:08
    Comment on lines 1427 to 1431
    .windows => {
    std.posix.abort();
    // This exit code is what Node.js uses when it calls
    // abort. This is relied on by their Node-API tests.
    bun.C.quick_exit(134);
    },
    Copy link
    Contributor Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Can we change Node's test so it accepts whatever exit code std.posix.abort results in?

    Comment on lines +1778 to +1784
    export fn Bun__crashHandler(message_ptr: [*]u8, message_len: usize) noreturn {
    crashHandler(.{ .panic = message_ptr[0..message_len] }, null, @returnAddress());
    }

    comptime {
    _ = &Bun__crashHandler;
    }
    Copy link
    Contributor Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    This should be unnecessary if we can get the WTF release assertions to work.

    Comment on lines 39 to 40
    // TODO(@heimskr): get finalizers in workers working again
    // checkOutput(requireAs(__filename, ['--expose-gc'], runOptions, 'worker'));
    Copy link
    Contributor Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Let's see if this test still fails

    @@ -8,6 +8,7 @@ static int cleanup_hook_count = 0;
    static void cleanup(void* arg) {
    cleanup_hook_count++;
    printf("cleanup(%d)\n", *(int*)(arg));
    fflush(stdout);
    Copy link
    Contributor Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Commit this change in 190n/node

    @@ -34,6 +34,7 @@ const failingNodeApiTests = [
    "test_threadsafe_function/test.js",
    "test_threadsafe_function/test_legacy_uncaught_exception.js",
    "test_worker_buffer_callback/test.js",
    "test_worker_buffer_callback/test-free-called.js", // TODO(@heimskr)
    Copy link
    Contributor Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Let's see if we can unskip this

    @@ -98,14 +104,14 @@ beforeAll(async () => {
    }
    }

    const parallelism = Math.min(8, os.cpus().length);
    const parallelism = Math.min(8, os.cpus().length, 1 /* TODO(@heimskr): remove */);
    Copy link
    Contributor Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    remove

    Comment on lines 73 to 76
    const start = Date.now();

    async function buildOne(dir: string) {
    console.log(`Building in ${dir.replace(/.+node-napi-tests.test./, "")}.`, (Date.now() - start) / 1000, "s elapsed");
    Copy link
    Contributor Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    remove

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    Wrap finalizer for PromiseRaw failed (@napi-rs/canvas) Segmentation fault | RakNet Module
    6 participants