Skip to content

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

@kraenhansen

Description

@kraenhansen

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 #331 as an example.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions