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 207 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
Fixes #15429

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 769c6de has 21 failures in #6904:

  • test/js/web/fetch/body-stream.test.ts - timeout on 🐧 3.20 x64
  • test/js/node/test/parallel/worker-nested-uncaught.test.js - segmentation fault on 🐧 3.20 x64-baseline
  • test/js/bun/http/bun-serve-static.test.ts - timeout on 🐧 3.20 x64-baseline
  • test/js/bun/http/bun-serve-static.test.ts - timeout on 🐧 3.20 x64
  • test/regression/issue/09041.test.ts - 1 failing on 🐧 12 x64-baseline
  • test/regression/issue/09041.test.ts - 1 failing on 🐧 3.20 x64-baseline
  • test/v8/v8.test.ts - 1 failing on 🐧 22.04 x64
  • test/v8/v8.test.ts - 22 failing on 🐧 3.20 aarch64
  • test/v8/v8.test.ts - 22 failing on 🐧 3.20 x64-baseline
  • test/v8/v8.test.ts - 22 failing on 🐧 3.20 x64
  • test/napi/node-napi.test.ts - 64 failing on 🐧 3.20 aarch64
  • test/napi/node-napi.test.ts - 64 failing on 🐧 3.20 x64-baseline
  • test/napi/node-napi.test.ts - 64 failing on 🐧 3.20 x64
  • test/integration/next-pages/test/dev-server.test.ts - 1 failing on 🐧 3.20 x64-baseline
  • test/integration/next-pages/test/dev-server.test.ts - 1 failing on 🐧 3.20 x64
  • test/cli/install/bun-create.test.ts - timeout on 🐧 11 x64
  • test/js/node/watch/fs.watch.test.ts - 5 failing on 🍎 14 aarch64
  • test/js/node/child_process/child_process.test.ts - 1 failing on 🐧 3.20 aarch64
  • test/js/node/child_process/child_process.test.ts - 1 failing on 🐧 3.20 x64-baseline
  • test/js/node/child_process/child_process.test.ts - 1 failing on 🐧 3.20 x64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 20.04 x64-baseline
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 22.04 x64-baseline
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 22.04 x64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 3.20 aarch64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 3.20 x64-baseline
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 3.20 x64
  • test/js/node/test/parallel/fs-watch-recursive-sync-write.test.js - 1 failing on 🍎 14 aarch64
  • test/cli/install/bun-link.test.ts - 1 failing on 🐧 3.20 aarch64
  • test/js/node/test/parallel/fs-watch-recursive-add-file-to-existing-subfolder.test.js - 1 failing on 🍎 14 aarch64
  • test/js/node/test/parallel/fs-watch-encoding.test.js - 3 failing on 🍎 14 aarch64
  • test/integration/next-pages/test/next-build.test.ts - 1 failing on 🐧 22.04 aarch64
  • test/integration/next-pages/test/next-build.test.ts - 1 failing on 🐧 22.04 x64-baseline
  • test/js/deno/performance/performance.test.ts - 1 failing on 🐧 22.04 aarch64
  • test/js/node/test/parallel/zlib.test.js - 1 failing on 🍎 13 aarch64
  • test/js/bun/http/serve.test.ts - 1 failing on 🍎 14 x64
  • test/js/bun/http/serve.test.ts - segmentation fault on 🐧 3.20 aarch64
  • test/js/bun/http/serve.test.ts - segmentation fault on 🐧 3.20 x64-baseline
  • test/js/bun/http/serve.test.ts - segmentation fault on 🐧 3.20 x64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🪟 2019 x64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🪟 2019 x64-baseline
  • test/js/third_party/prisma/prisma.test.ts - 1 failing on 🍎 13 aarch64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🍎 14 aarch64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🍎 13 x64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🍎 14 x64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 22.04 aarch64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 20.04 aarch64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 11 aarch64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 12 aarch64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 20.04 x64-baseline
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 12 x64-baseline
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 11 x64-baseline
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 22.04 x64-baseline
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 22.04 x64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 20.04 x64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 12 x64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 3.20 aarch64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 3.20 x64-baseline
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 11 x64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 3.20 x64
  • test/cli/hot/hot.test.ts - timeout on 🍎 14 aarch64
  • test/cli/hot/hot.test.ts - timeout on 🐧 22.04 x64
  • test/cli/hot/hot.test.ts - timeout on 🐧 3.20 x64-baseline
  • @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
    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

    @@ -770,6 +770,8 @@ pub const EventLoop = struct {
    immediate_tasks: Queue = undefined,
    next_immediate_tasks: Queue = undefined,

    napi_finalizer_queue: JSC.napi.Finalizer.Queue = undefined,
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    definitely shouldn't be undefined

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