Check preconditions of the project's configuration (Cargo.toml)

Open
#312 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
react-native, rust
Domain
api, build-system

Research direction

Start with the project's Cargo.toml and compare its napi dependency configuration with the ferric-example Cargo.toml and the Node-API version matrix. Trace how napi-rs dependencies are resolved; done means unsupported Node-API versions produce a clear failure before runtime rather than an abort.

Written by the indexing model from the issue text.

Description

enhancement Ferric 🦀 good first issue

We're still lacking implementation of some Node-API runtime functions. For the time being, it would be great if we inspected the Cargo.toml and provide a neat explanation if the developer is building for a version of Node-API we don't currently support.

The alternative is aborts at runtime, similar to:

[DEBUG] [NodeApiHost] [pshenmic-dpp-napi--dpp] Loading addon by '@rpath/pshenmic-dpp-napi--dpp.framework/pshenmic-dpp-napi--dpp'
[DEBUG] [NodeApiHost] [pshenmic-dpp-napi--dpp] Loaded addon
[DEBUG] [NodeApiHost] [pshenmic-dpp-napi--dpp] Found napi_register_module_v1 (0x103a09294)
Node-API function 'napi_create_threadsafe_function' called before it was injected!

The workaround is to downgrade the Node-API version declared in your Cargo.toml as per the ferric-example.

[dependencies.napi]
version = "3.4.0"
# see https://nodejs.org/api/n-api.html#node-api-version-matrix
default-features = false
features = ["napi3"]

We should also fail fast if the project resolves their dependency of napi-rs dependencies to something we're not compatible with, see https://github.com/callstackincubator/react-native-node-api/issues/331 as an example.

Dominant language
TypeScript
Stars
206
Forks
12
Avg merge
4h 8m
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from callstackincubator/react-native-node-api

All issues in callstackincubator/react-native-node-api

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.