Code Monkey home page Code Monkey logo

weak-napi's Introduction

node-ffi-napi

Node.js Foreign Function Interface for N-API

Greenkeeper badge

NPM Version NPM Downloads Build Status Coverage Status Dependency Status

node-ffi-napi is a Node.js addon for loading and calling dynamic libraries using pure JavaScript. It can be used to create bindings to native libraries without writing any C++ code.

It also simplifies the augmentation of node.js with C code as it takes care of handling the translation of types across JavaScript and C, which can add reams of boilerplate code to your otherwise simple C. See the example/factorial for an example of this use case.

WARNING: node-ffi-napi assumes you know what you're doing. You can pretty easily create situations where you will segfault the interpreter and unless you've got C debugger skills, you probably won't know what's going on.

WARNING: The original API of node-ffi is left mostly untouched in the N-API wrapper. However, the API did not have very well-defined properties in the context of garbage collection and multi-threaded execution. It is recommended to avoid any multi-threading usage of this library if possible.

Example

var ffi = require('ffi-napi');

var libm = ffi.Library('libm', {
  'ceil': [ 'double', [ 'double' ] ]
});
libm.ceil(1.5); // 2

// You can also access just functions in the current process by passing a null
var current = ffi.Library(null, {
  'atoi': [ 'int', [ 'string' ] ]
});
current.atoi('1234'); // 1234

For a more detailed introduction, see the node-ffi tutorial page.

Requirements

  • Linux, OS X, Windows, or Solaris.
  • libffi comes bundled with node-ffi-napi; it does not need to be installed on your system.
  • The current version is tested to run on Node 6 and above.

Installation

Make sure you've installed all the necessary build tools for your platform, then invoke:

$ npm install ffi-napi

Source Install / Manual Compilation

To compile from source it's easiest to use node-gyp:

$ npm install -g node-gyp

Now you can compile node-ffi-napi:

$ git clone git://github.com/node-ffi-napi/node-ffi-napi.git
$ cd node-ffi
$ node-gyp rebuild

Types

The types that you specify in function declarations correspond to ref's types system. So see its docs for a reference if you are unfamiliar.

V8 and 64-bit Types

Internally, V8 stores integers that will fit into a 32-bit space in a 32-bit integer, and those that fall outside of this get put into double-precision floating point numbers. This is problematic because FP numbers are imprecise. To get around this, the methods in node-ffi that deal with 64-bit integers return strings and can accept strings as parameters.

Call Overhead

There is non-trivial overhead associated with FFI calls. Comparing a hard-coded binding version of strtoul() to an FFI version of strtoul() shows that the native hard-coded binding is orders of magnitude faster. So don't just use the C version of a function just because it's faster. There's a significant cost in FFI calls, so make them worth it.

License

MIT License. See the LICENSE file.

weak-napi's People

Contributors

19h avatar addaleax avatar bnoordhuis avatar duralog avatar greenkeeper[bot] avatar imyller avatar joshuef avatar kkoopa avatar laverdet avatar metamatt avatar piotrkobzda avatar robcolburn avatar rvagg avatar simenb avatar tootallnate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

weak-napi's Issues

An in-range update of setimmediate-napi is breaking the build 🚨

The dependency setimmediate-napi was updated from 1.0.4 to 1.0.5.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

setimmediate-napi is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/appveyor/branch: Waiting for AppVeyor build to complete (Details).
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).
  • coverage/coveralls: First build on greenkeeper/setimmediate-napi-1.0.5 at 100.0% (Details).

Commits

The new version differs by 1 commits.

  • 6354c84 Always inuclude get-symbol-from-current-process.h (v1.0.5)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Segfault on process shutdown with vm.createContext

This code causes node to segfault on exit.

function run() {
  let vm = require('vm');
  let ctx = vm.createContext();
  let scr = new vm.Script('({})');
  require('weak-napi')(ctx, () => console.log('freed'));
  scr.runInContext(ctx);
}

run();
ketchup% npm i weak-napi && node alpha.js 
zsh: segmentation fault (core dumped)  node alpha.js

Sometimes(:tm:) you can fix this by adding global.gc() before the script exits, but that's defeatable, e.g. with this, which segfaults again:

let vm = require('vm');
let ctx = vm.createContext();
let scr = new vm.Script('({"bar":function(require){require("https").get = () => {};}})');
scr.runInContext(ctx).bar(require);
require('weak-napi')(ctx, () => console.log('freed'))
vm = null; ctx = null; scr = null;
global.gc();

The backtrace is meaningless to me; it's trying to clean up the environment and it's trying a double-free. Ooh, I wonder if ASAN will catch this? Note that the backtrace is way worse on older nodes.

ketchup% gdb --args ~/clone/node/out/Debug/node alpha.js
...
Thread 1 "node" received signal SIGSEGV, Segmentation fault.
0x000055837b4de4b2 in v8impl::(anonymous namespace)::RefBase::Delete (reference=0x558381065540) at ../src/js_native_api_v8.cc:248
248	      delete reference;
(gdb) bt
#0  0x000055837b4de4b2 in v8impl::(anonymous namespace)::RefBase::Delete (reference=0x558381065540) at ../src/js_native_api_v8.cc:248
#1  v8impl::(anonymous namespace)::RefBase::Finalize (this=0x558381065540, is_env_teardown=<optimised out>)
    at ../src/js_native_api_v8.cc:281
#2  0x000055837b4feb4c in v8impl::RefTracker::FinalizeAll (list=0x558381109d08) at ../src/js_native_api_v8.h:43
#3  napi_env__::~napi_env__ (this=0x558381109cd0, __in_chrg=<optimised out>) at ../src/js_native_api_v8.h:66
#4  node_napi_env__::~node_napi_env__ (this=0x558381109cd0, __in_chrg=<optimised out>) at ../src/node_api.cc:17
#5  node_napi_env__::~node_napi_env__ (this=0x558381109cd0, __in_chrg=<optimised out>) at ../src/node_api.cc:17
#6  0x000055837b4fa0c2 in napi_env__::Unref (this=<optimised out>) at ../src/js_native_api_v8.h:77
#7  operator() (arg=<optimised out>, __closure=0x0) at ../src/node_api.cc:103
#8  _FUN () at ../src/node_api.cc:104
#9  0x000055837b4d18ec in node::Environment::RunCleanup (this=this@entry=0x558380ff2830) at ../src/env.cc:661
#10 0x000055837b4797ef in node::FreeEnvironment (env=0x558380ff2830) at ../src/api/environment.cc:371
#11 0x000055837b57deb1 in node::FunctionDeleter<node::Environment, &node::FreeEnvironment>::operator() (pointer=<optimised out>, 
    this=0x7ffed4b26e30) at ../src/util.h:636
#12 std::unique_ptr<node::Environment, node::FunctionDeleter<node::Environment, &node::FreeEnvironment> >::~unique_ptr (
    this=0x7ffed4b26e30, __in_chrg=<optimised out>) at /usr/include/c++/10/bits/unique_ptr.h:361
#13 node::NodeMainInstance::Run (this=this@entry=0x7ffed4b26f80, env_info=env_info@entry=0x55837fa57780 <node::env_info>)
    at ../src/node_main_instance.cc:135
#14 0x000055837b4f7908 in node::Start (argc=<optimised out>, argv=<optimised out>) at ../src/node.cc:1078
#15 0x000055837cb7cb63 in main (argc=2, argv=0x7ffed4b271b8) at ../src/node_main.cc:127
ketchup% node --version
v12.20.0

Debug node built is from HEAD today (d90fa196c5540109bf9c5063f8c51673340ad9e3). Ubuntu 20.10, amd64.


I found this trying to diagnose jestjs/jest#10289 ; this createContext / runInContext dance is how Jest works. However, I assume Jest works for most people most of the time, so it can't always segfault. As far as I can see, Jest always use Script to load user code, with most core modules require'd like in the second bit of code.

An in-range update of mocha is breaking the build 🚨

Version 5.2.0 of mocha was just published.

Branch Build failing 🚨
Dependency mocha
Current Version 5.1.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

mocha is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build passed Details
  • coverage/coveralls First build on greenkeeper/mocha-5.2.0 at 100.0% Details
  • continuous-integration/appveyor/branch AppVeyor build failed Details

Release Notes v5.2.0

5.2.0 / 2018-05-18

🎉 Enhancements

🐛 Fixes

📖 Documentation

🔩 Other

Commits

The new version differs by 30 commits.

  • 5bd33a0 Release v5.2.0
  • 0a5604f reformat missed files
  • 7c8f551 ensure scripts/*.js gets prettiered
  • d8ea2ba update CHANGELOG.md for v5.2.0 [ci skip]
  • 7203ed7 update all dependencies
  • fb5393b migrate Mocha's tests to Unexpected assertion library (#3343)
  • fae9af2 docs(docs/index.md): Update "mocha.opts" documentation
  • 9d9e6c6 feat(bin/options.js): Add support for comment lines in "mocha.opts"
  • e0306ff fix busted lint-staged config
  • f2be6d4 Annotate when exceptions are caught but ignored; closes #3354 (#3356)
  • 889e681 remove dead code in bin/_mocha
  • 8712b95 fix(ocd): re-order Node.js tests in .travis.yml (descending)
  • 3ab0e7e fix to exit correctly when using bail flag
  • d87b12e add Node.js v10 to build; fix win32 issues (#3350)
  • b392af5 update package-lock.json for npm@6 [ci skip]

There are 30 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

An in-range update of node-gyp-build is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The dependency node-gyp-build was updated from 4.2.1 to 4.2.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

node-gyp-build is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/appveyor/branch: AppVeyor build failed (Details).

Commits

The new version differs by 3 commits.

  • 7e1f184 4.2.2
  • cadbc9a Use env.npm_config_* for electron and upcoming npm (#30)
  • e046b9f Upgrade tape devDependency to 5.0.0 (#31)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

node-gyp cannot rebuild

Hi,
I'm trying to install a nodejs project that uses weak-napi as a dependency of another package.
I've tried several node, yarn, python and node-gyp versions, all with the same result:

yarn install
yarn install v1.19.1
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
[-/7] ⢀ waiting...
[-/7] ⢀ waiting...
[-/7] ⢀ waiting...
[4/7] ⢀ weak-napi
error /Users/****/node_modules/weak-napi: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /Users/****/node_modules/weak-napi
Output:
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info find Python using Python version 2.7.10 found at "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python"
gyp http GET https://nodejs.org/download/release/v10.17.0/node-v10.17.0-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v10.17.0/node-v10.17.0-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v10.17.0/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v10.17.0/SHASUMS256.txt
gyp info spawn /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
gyp info spawn args [ '/Users/****/.nvm/versions/node/v10.17.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/****/node_modules/weak-napi/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/****/.nvm/versions/node/v10.17.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/****/Library/Caches/node-gyp/10.17.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/****/Library/Caches/node-gyp/10.17.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/****/.nvm/versions/node/v10.17.0/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/****/Library/Caches/node-gyp/10.17.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/****/node_modules/weak-napi',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o
  LIBTOOL-STATIC Release/nothing.a
Traceback (most recent call last):
  File "./gyp-mac-tool", line 611, in <module>
    sys.exit(main(sys.argv[1:]))
  File "./gyp-mac-tool", line 30, in main
    exit_code = executor.Dispatch(args)
  File "./gyp-mac-tool", line 45, in Dispatch
    return getattr(self, method)(*args[1:])
  File "./gyp-mac-tool", line 248, in ExecFilterLibtool
    if not libtool_re.match(line) and not libtool_re5.match(line):
TypeError: cannot use a string pattern on a bytes-like object
make: *** [Release/nothing.a] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/****/.nvm/versions/node/v10.17.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:193:23)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/Users/****/.nvm/versions/node/v10.17.0/bin/node" "/Users/****/.nvm/versions/node/v10.17.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/****/node_modules/weak-napi****

I've opened an issue in the node-gyp's git as well but I think the problem is related to the weak-napi installation.

Can you help me with this issue, please? Thanks

An in-range update of nyc is breaking the build 🚨

Version 11.7.3 of nyc was just published.

Branch Build failing 🚨
Dependency nyc
Current Version 11.7.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

nyc is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details
  • coverage/coveralls First build on greenkeeper/nyc-11.7.3 at 100.0% Details
  • continuous-integration/appveyor/branch AppVeyor build succeeded Details

Commits

The new version differs by 2 commits.

  • 43bda0c chore(release): 11.7.3
  • c20f8da security: address all vulnerabilities (#836)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Build is failing a lot with "Error: read ECONNRESET"

In the past few days, our project has started experiencing a lot of installation issues with this package. The error always looks like this:

+ yarn install --frozen-lockfile
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
warning Error running install script for optional dependency: ".../node_modules/weak-napi: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments: 
Directory: .../node_modules/weak-napi
Output:
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info find Python using Python version 2.7.13 found at \"/usr/bin/python\"
gyp http GET https://nodejs.org/download/release/v12.16.3/node-v12.16.3-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v12.16.3/node-v12.16.3-headers.tar.gz
gyp WARN install got an error, rolling back install
gyp ERR! configure error 
01:07:26 
 gyp ERR! stack Error: read ECONNRESET
gyp ERR! stack     at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)
gyp ERR! System Linux 4.19.123-coreos
gyp ERR! command \"/usr/local/bin/node\" \"/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js\" \"rebuild\"
gyp ERR! cwd .../node_modules/weak-napi
gyp ERR! node -v v12.16.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok"

We don't have networking issues with anything else at the moment. This is the only package/tool giving us problems.

An in-range update of setimmediate-napi is breaking the build 🚨

The dependency setimmediate-napi was updated from 1.0.5 to 1.0.6.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

setimmediate-napi is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build passed (Details).
  • coverage/coveralls: First build on greenkeeper/setimmediate-napi-1.0.6 at 100.0% (Details).
  • continuous-integration/appveyor/branch: AppVeyor build failed (Details).

Commits

The new version differs by 2 commits.

  • 47e8238 v1.0.6
  • 002c7d6 Fix paths-with-spaces handling for Windows builds

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Handling of JavaScript errors in ObjectInfo's callback

It looks like errors thrown by ObjectInfo's callback cannot be caught in process' "uncaughtException" event.

What's even more surprising is that the error is subsequently thrown the next time an ObjectInfo is constructed.

The workaround is to wrap the callback into a setImmediate call, but that shouldn't be necessary since the native side already does that.

I have a feeling this is an issue for https://github.com/node-ffi-napi/setimmediate-napi

From a quick research I guess calling napi_fatal_exception instead of e.ThrowAsJavaScriptException() would do the trick, but I'm probably out of my depth here.

Repro:

const { ObjectInfo, WeakTag } = require("@mhofman/weak-napi-native");

const map = new WeakMap();

async function test(call) {
    let listener;

    const thrown = new Promise(resolve => {
        listener = error => void resolve(error);
        process.on("uncaughtException", listener);
    });

    let object = {};
    const info = new ObjectInfo(object, () => {
        call(() => {
            throw new Error(
                "I should be able to get this in uncaughtException"
            );
        });
    });

    map.set(object, new WeakTag(info));

    object = undefined;
    await Promise.resolve(resolve => setImmediate(resolve));
    gc();

    const result = await Promise.race([
        thrown,
        new Promise(resolve => setTimeout(resolve, 200, "Bailing")),
    ]);

    process.removeListener("uncaughtException", listener);

    return result;
}

(async () => {
    console.log("setImmediate start");
    console.log(
        "setImmediate",
        await test(fn => {
            console.log("setImmediate callback invoked");
            setImmediate(fn);
        })
    );

    console.log("direct start");
    console.log(
        "direct",
        await test(fn => {
            console.log("direct callback invoked");
            fn();
        })
    );

    try {
        const info = new ObjectInfo({}, () => {});
    } catch (error) {
        console.log("Caught error on construct", error);
    }

    console.log("done");

    process.exit();
})();

Output:

setImmediate start
setImmediate callback invoked
setImmediate Error: I should be able to get this in uncaughtException
direct start
direct callback invoked
direct Bailing
Caught error on construct Error: I should be able to get this in uncaughtException
done

Build fails when project path contains a space

I believe the issue is in this package and not in node-gyp, because I have another package that needs node-gyp to be built in the same project and that one doesn't fail.

Here's the log:

> [email protected] install /Users/benface/Desktop/Dev/Project with space/node_modules/weak-napi
> node-gyp rebuild

  CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o
  LIBTOOL-STATIC Release/nothing.a
  CXX(target) Release/obj.target/weakref/src/weakref.o
clang: error: no such file or directory: 'with'
clang: error: no such file or directory: 'space/node_modules/node-addon-api'
make: *** [Release/obj.target/weakref/src/weakref.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:305:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.2.0
gyp ERR! command "/usr/local/Cellar/node/13.5.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/benface/Desktop/Dev/Project with space/node_modules/weak-napi
gyp ERR! node -v v13.5.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok 
npm WARN [email protected] requires a peer of node-sass@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of fibers@>= 3.1.0 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Notice these lines in particular, which shows that something splits the path where there's a space:

clang: error: no such file or directory: 'with'
clang: error: no such file or directory: 'space/node_modules/node-addon-api'

Thank you!

An in-range update of node-addon-api is breaking the build 🚨

The dependency node-addon-api was updated from 1.4.0 to 1.5.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

node-addon-api is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/appveyor/branch: Waiting for AppVeyor build to complete (Details).
  • coverage/coveralls: Coverage pending from Coveralls.io (Details).
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 32 commits.

  • ffebf9b Updates for release 1.5.0
  • 2234749 doc: update Version management
  • 917bd60 src: remove TODOs by fixing memory leaks
  • dfcb939 src: implement AsyncContext class
  • 4f76262 doc: some fix on Napi::Boolean documentation
  • 78374f7 doc: number documentation
  • 779560f test: add operator overloading tests in Number
  • 51ffe45 doc: doc cleanup
  • 211ed38 src: make 'nothing' target a static library
  • fd3c37b tools: add tool to check for N-API modules
  • fc11c94 doc: major doc cleanup
  • 97c4ab5 src: add Call and MakeCallback that accept cargs
  • 73fed84 test: add ability to control experimental tests
  • b6e2d92 src: enable DataView feature by default
  • 0a00e7c src: implement missing descriptor defs for symbols

There are 32 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Cannot open include file: 'setimmediate.h'

fatal error C1083: Cannot open include file: 'setimmediate.h': No such file or directory

(during npm install after a fresh re-install/upgrade of npm 12.10.0, on an existing project that previously worked fine)

I'm so confused. setimmediate-napi IS listed as a dependency, so why can't it find it?

An in-range update of node-addon-api is breaking the build 🚨

The dependency node-addon-api was updated from 1.5.0 to 1.6.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

node-addon-api is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).
  • coverage/coveralls: First build on greenkeeper/node-addon-api-1.6.0 at 100.0% (Details).
  • continuous-integration/appveyor/branch: AppVeyor build failed (Details).

Release Notes for Release 1.6.0

SemVer minor release to pull changes since the last release. Mostly minor fixes and additions. The motivations for release are the addition of a new feature Napi::CallbackScope, that helps to have the equivalent of the scope associated with a callback in place when making certain N-API calls. Furthermore there are some additions on tests and improvements on documentation about the ABI stability.

Commits

The new version differs by 9 commits.

  • 322dc09 Updates for release 1.6.0
  • 8ce605c build: avoid using package-lock.json
  • fa3a615 src: use MakeCallback() -> Call() in AsyncWorker
  • 2342415 test: create test objects in the stack instead of the heap
  • 67b7db0 test: write tests for Array class
  • 729f6dc test: add arraybuffer tests
  • 405f3e5 src: implement CallbackScope class
  • 015d953 doc: fix Napi::Reference link
  • fd65078 README.md: link to new ABI stability guide

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of setimmediate-napi is breaking the build 🚨

The dependency setimmediate-napi was updated from 1.0.3 to 1.0.4.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

setimmediate-napi is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/appveyor/branch: Waiting for AppVeyor build to complete (Details).
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).
  • coverage/coveralls: First build on greenkeeper/setimmediate-napi-1.0.4 at 100.0% (Details).

Commits

The new version differs by 6 commits.

  • 1d4d986 v1.0.4
  • 281e54a Fix catch-value warning
  • 12e4aae chore(package): update get-uv-event-loop-napi-h to version 1.0.5 (#5)
  • e4cab6a Enhance ABI compatibility for libuv functions
  • 58f41f6 Add Greenkeeper badge
  • 8c6a2ac Mention #include in readme

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Segfault in node 12

Not sure what's going on, but in Node 12, I'm getting some segfaults. I've traced it to ObjectInfo.target calls after the target has been collected, but it doesn't seem to always trigger.

To reproduce, just run the test suite of your package, or npm run test:node of https://github.com/mhofman/tc39-weakrefs-shim

Segmentation fault

I was trying to set up a simple example of using this library, but I can't seem to use it at all without encountering segmentation faults. Even this example is producing a segmentation fault for me:

let weak = require('weak-napi');
let x = { foo: 'bar' };
let y = weak(x);
$ node test.js
Segmentation fault (core dumped)

Is this just me? Am I doing something wrong?

I am running node v12.18.2 on Ubuntu 20.10.

Fatal Crash

Sudden crashes happen to node with this ambiguous error

FATAL ERROR: v8::HandleScope::CreateHandle() Cannot create a handle without a HandleScope
 1: 00007FF6503A470F napi_wrap+113583
 2: 00007FF65034F7D6 v8::base::CPU::has_sse+66646
 3: 00007FF6503505D6 v8::base::CPU::has_sse+70230
 4: 00007FF650B6425C v8::FunctionTemplate::RemovePrototype+284
 5: 00007FF650A49315 v8::internal::HandleScope::Extend+53
 6: 00007FF650B49115 v8::HandleScope::CreateHandle+37
 7: 00007FF650385D0A napi_get_reference_value+106
 8: 00007FFF67238690 
 9: 00007FFF6723A578
10: 00007FF650380D38 node::Stop+29480
11: 00007FF650372D7C node_module_register+572
12: 00007FF650373084 node_module_register+1348
13: 00007FF6503A311D napi_wrap+107965
14: 00007FF650293701 v8::internal::interpreter::BytecodeLabel::bind+5009
15: 00007FF650297778 v8::internal::interpreter::BytecodeLabel::bind+21512
16: 00007FF650293F32 v8::internal::interpreter::BytecodeLabel::bind+7106
17: 00007FF6503E51BD uv_poll_stop+765
18: 00007FF6510A8430 v8::internal::SetupIsolateDelegate::SetupHeap+1532832
19: 00007FFF8D147BD4 BaseThreadInitThunk+20
20: 00007FFF8E44CE51 RtlUserThreadStart+33

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

fail test at 'should invoke *all* callbacks from different weak references'

Node version 10.8.0
platform windows 7 x64

when i run npm test, segment fault cause the mocha test failed.

the error happend at test/callback.js line 64

it('should invoke *all* callbacks from different weak references',
   function(done) {
  let obj = {};
  const r1 = weak(obj);
  const r2 = weak(obj);
  assert.strictEqual(weak.get(r1), obj);
  assert.strictEqual(weak.isDead(r1), false);
  obj = null;
  let called1 = false;
  let called2 = false;
  weak.addCallback(r1, function() {
    called1 = true
  });
  weak.addCallback(r2, function() {
    called2 = true
  });
  gc();
  setImmediate(() => {
    assert.strictEqual(weak.get(r1), undefined);   // <<-- Here segment fault
    assert.strictEqual(weak.isDead(r1), true);
    assert(called1);
    assert(called2);
    done();
  });
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.