Skip to content

Implementation of V1 buffer runtime functions #168

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

Merged
merged 14 commits into from
Jul 11, 2025

Conversation

paradowstack
Copy link
Contributor

This PR brings in an implementation of following V1 buffer runtime functions:

  • napi_create_buffer
  • napi_create_buffer_copy
  • napi_is_buffer
  • napi_get_buffer_info
  • napi_create_external_buffer

It also introduces test addon, adopted from https://github.com/nodejs/node/tree/main/test/node-api/test_buffer, that is placed in packages/node-addon-examples/tests/buffers.

Copy link

changeset-bot bot commented Jul 10, 2025

⚠️ No Changeset found

Latest commit: 2441fc8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@paradowstack paradowstack marked this pull request as ready for review July 10, 2025 12:31
console.log(addon.newBuffer().toLocaleString(), addon.theText);
console.log("gc1");
console.log(addon.getDeleterCallCount(), 0);
global.gc();
Copy link
Collaborator

@kraenhansen kraenhansen Jul 10, 2025

Choose a reason for hiding this comment

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

I don't expect this to be defined when running in React Native.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From what I can see Hermes C++ API does not provide a way to trigger a garbage collection. I think without patching the Hermes it won't be possible to run this part of test when running in React Native - please correct me if I am wrong. In this case I will remove it for now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a good point and perhaps something we need to ask @vmoroz or @tmikov.

Copy link
Collaborator

@kraenhansen kraenhansen Jul 11, 2025

Choose a reason for hiding this comment

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

Turns out I was wrong 🎉 globalThis.gc() should be available 🦾

@kraenhansen
Copy link
Collaborator

kraenhansen commented Jul 11, 2025

@paradowstack when you're ready to run the tests on Android and iOS you can add the two labels to the PR (not yet well documented). I just did this now, hope that's okay with you 🙏

Copy link
Collaborator

@kraenhansen kraenhansen left a comment

Choose a reason for hiding this comment

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

I think it's okay to merge once the Android and iOS tests has passed and look forward to improving the tests with #147.

@kraenhansen kraenhansen added Apple 🍎 Anything related to the Apple platform (iOS, macOS, Cocoapods, Xcode, XCFrameworks, etc.) Android 🤖 Anything related to the Android platform (Gradle, NDK, Android SDK) labels Jul 11, 2025
@paradowstack paradowstack merged commit 5cbffb8 into main Jul 11, 2025
18 checks passed
@paradowstack paradowstack deleted the kp/buffers-runtime-functions branch July 11, 2025 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android 🤖 Anything related to the Android platform (Gradle, NDK, Android SDK) Apple 🍎 Anything related to the Apple platform (iOS, macOS, Cocoapods, Xcode, XCFrameworks, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants