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

[bindgen] Adding prebuild and configuring it #5447

Merged
merged 1 commit into from
Feb 22, 2023

Conversation

kraenhansen
Copy link
Member

What, How & Why?

This adds prebuild of the Node.js native module for separate architectures.

For context, I've included an excerpt from an internal discussion we had on Slack:


I just learned that uv.h is not covered by the ABI stability of node-api: https://nodejs.org/dist/latest-v18.x/docs/api/n-api.html#implications-of-abi-stability
In our current SDK we use a pre v7 version of cmake-js, which incorrectly assumes we're building for a specific node version and incorrectly expose uv.h to object-store and risking crashes.
I noticed this when I upgraded to cmake-js v7.1.1 on master where it correctly detects that we want to compile for node-api (because of this check) and I start getting:

object-store/util/uv/scheduler.hpp:24:10: fatal error: 'uv.h' file not found

I believe this means that we're risking crashes of our current native binary, because we're depending on the ABI of libuv, which we can't assume is stable.

I see the following options:

  • Implement a scheduler on top of the node-api primitives for async operations - if that's even possible? @fealebenpae suggested making a scheduler using the Napi::ThreadSafeFunction API.
  • Include our own copy of libuv and somehow integrate it with that provided by node.js (but the integration code will be exposed to the same risks if prebuilt).
  • Avoid upgrading cmake-js or build for node (instead of napi) and cross our fingers and hope it won't break in future versions of node 🤞

This PR takes the latter approach by avoiding to include the

@kraenhansen kraenhansen self-assigned this Feb 16, 2023
@cla-bot cla-bot bot added the cla: yes label Feb 16, 2023
@kraenhansen kraenhansen changed the title [bindgen] Adding " and configuring it [bindgen] Adding prebuild and configuring it Feb 16, 2023
Copy link
Contributor

@takameyer takameyer left a comment

Choose a reason for hiding this comment

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

Looks good. Just curious how this avoids importing uv.h

Comment on lines +80 to +85
"binary": {
"module_name": "realm",
"module_path": "generated/ts",
"host": "https://static.realm.io",
"package_name": "realm-v{version}-napi-v6-{platform}-{arch}.tar.gz",
"remote_path": "realm-js-prebuilds/{version}"
Copy link
Member Author

Choose a reason for hiding this comment

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

Because we're leaving out the api_versions from this object, we signal to cmake-js that we're not targeting napi explicitly, which ensures we get the uv.h in our include path.

Copy link
Member Author

@kraenhansen kraenhansen Feb 21, 2023

Choose a reason for hiding this comment

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

Just curious how this avoids importing uv.h

@takameyer this is where the magic happens 🪄

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you 🤩

@kraenhansen kraenhansen merged commit 0b23404 into bindgen Feb 22, 2023
@kraenhansen kraenhansen deleted the kh/bindgen/prebuild branch February 22, 2023 09:14
papafe added a commit that referenced this pull request Feb 24, 2023
* bindgen:
  Implement getAllSyncSessions (#5492)
  Ensure that Realm enums are accessible (#5484)
  Apply suggestions from code review [skip ci]
  Small corrections [skip ci]
  Added changelog and final corrections
  Stub
  add test to validate that foreach throws on a dictionary (#5467)
  Using `RealmInsertionModel` on `Results#update`
  Updated "react-native" dev dep to 0.71.0
  Bumped lower bound on our RN peer dependency
  [bindgen] SDK packaging (#5466)
  Adding "prebuild" and configuring it (#5447)
  add synthetic private brand fields to TS wrappers for C++ classes, and fix found bug
  import bindings directly rather than through internal
  Stub work
kraenhansen added a commit that referenced this pull request Mar 1, 2023
kraenhansen added a commit that referenced this pull request Mar 3, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants