Skip to content

electron-gyp Node Nan boolean being returned as false #6318

Closed

Description

@drFabio
  • Electron version: 1.1.1
  • Operating system: Linux x64

While doing a node-gyp program using NaN when compiling with electron with the following command:

~/.electron-gyp node-gyp rebuild --target=1.1.1 --arch=x64 --dist-url=https://atom.io/download/atom-shell --verbose

The following node-gyp binding:

 #include <nan.h>

using namespace v8;


void example(const Nan::FunctionCallbackInfo<v8::Value>& info) {
  info.GetReturnValue().Set(Nan::True());
}
void example2(const Nan::FunctionCallbackInfo<v8::Value>& info) {
  info.GetReturnValue().Set(Nan::New(true));
}
void example3(const Nan::FunctionCallbackInfo<v8::Value>& info) {
  v8::Local<v8::Function> cb = info[0].As<v8::Function>();
  const unsigned argc = 1;
  v8::Local<v8::Value> argv[argc] = {Nan::New(true)};
  Nan::MakeCallback(Nan::GetCurrentContext()->Global(), cb, argc, argv);
}
void example4(const Nan::FunctionCallbackInfo<v8::Value>& info) {
  v8::Local<v8::Function> cb = info[0].As<v8::Function>();
  const unsigned argc = 1;
  v8::Local<v8::Value> argv[argc] = {Nan::True()};
  Nan::MakeCallback(Nan::GetCurrentContext()->Global(), cb, argc, argv);
}

void InitAll(v8::Local<v8::Object> exports) {

  exports->Set(Nan::New("example").ToLocalChecked(),
      Nan::New<v8::FunctionTemplate>(example)->GetFunction());
    exports->Set(Nan::New("example2").ToLocalChecked(),
      Nan::New<v8::FunctionTemplate>(example2)->GetFunction());
      exports->Set(Nan::New("example3").ToLocalChecked(),
      Nan::New<v8::FunctionTemplate>(example3)->GetFunction());
      exports->Set(Nan::New("example4").ToLocalChecked(),
      Nan::New<v8::FunctionTemplate>(example4)->GetFunction());
}

NODE_MODULE(boolExample, InitAll)

Is always returning false when on electron, the same code on pure Node returns true , I am requiring the generator .node file directly on electron.

Activity

  1. kevinsawicki commented on Jul 1, 2016

    @kevinsawicki
    Contributor

    I wonder if this is related to #5851 (comment)

  2. anaisbetts commented on Jul 1, 2016

    @anaisbetts
    Contributor

    I've seen bugs like this in Spellchecker that did stuff like this

  3. added
    blocked/need-info ❌
    and removed on Jul 2, 2016
  4. zcbenz commented on Jul 2, 2016

    @zcbenz
    Contributor

    If you build the native module for v1.1.x and then use it in v1.2.x, you will see this problem, and that's already tracked in #5851. Otherwise when you build the module from source code everything should be working.

  5. drFabio commented on Jul 2, 2016

    @drFabio
    Author

    @zcbenz Yeah, totally my bad , did not realized the package.json had electron pre-build as ^1.1.1 . The installed version was 1.2.5 and I was targeting 1.1.1 on the build making this behaviour.

    Thanks for your time and insight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    blocked/need-info ❌

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions