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

gRPC 1.1 + electron 1.4.15 = problems #10458

Closed
andresiraola opened this issue Apr 4, 2017 · 5 comments
Closed

gRPC 1.1 + electron 1.4.15 = problems #10458

andresiraola opened this issue Apr 4, 2017 · 5 comments
Assignees

Comments

@andresiraola
Copy link

The compiled grpc_node.node installed via node-pre-gyp gets loaded correctly in electron 1.4.15 but it makes my electron crash just after a function call. The client gets loaded correctly and the server get to receive the message but it seems that the client (in electron) crashes when it gets the answer.

So, I tried to build the module 'from sources' using electron-rebuild but it didn't work. After a lot of review of the issue, I realized that the problem is the WINDOWS_BUILD_WARNING project. In my console I get:

'"echo"' is not recognized as an internal or external command,

gyp adds quotes around the echo command and the win10 console doesn't seem to like it.

The solution I found is to change that action by a rule in binding.gyp which allowed me to build the module correctly.

{
  # IMPORTANT WINDOWS BUILD INFORMATION
  # This library does not build on Windows without modifying the Node
  # development packages that node-gyp downloads in order to build.
  # Due to https://github.com/nodejs/node/issues/4932, the headers for
  # BoringSSL conflict with the OpenSSL headers included by default
  # when including the Node headers. The remedy for this is to remove
  # the OpenSSL headers, from the downloaded Node development package,
  # which is typically located in `.node-gyp` in your home directory.
  'target_name': 'WINDOWS_BUILD_WARNING',
  'rules': [
    {
      'rule_name': 'WINDOWS_BUILD_WARNING',
      'extension': 'S',
      'inputs': [
        'package.json'
      ],
      'outputs': [
        'ignore_this_part'
      ],
      'action': ['echo', 'IMPORTANT: Due to https://github.com/nodejs/node/issues/4932, to build this library on Windows, you must first remove <(node_root_dir)/include/node/openssl/']
    }
  ]
}

With the module built locally, my electron app works as expected; no crashes no nothing. So it seems the version hosted here: https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.1.0/electron-v1.4-win32-x64.tar.gz doesn't sympathize with electron 1.4.15.

So it would be nice if you can upload a good version of the module for electorn 1.4**.15** and fix the issue of the quotes in the warning project.

Platform: nodejs + electron
Grpc version: 1.1.0
OS: win10 (14393.969)

@murgatroid99
Copy link
Member

Are you sure that when you installed gRPC, you got the electron precompiled binaries? Did you set the environment variables specified in the electron documentation? If you do that, you should omit the build_from_source argument, to make sure that it downloads the precompiled binary.

@andresiraola
Copy link
Author

Yes, I'm sure.

I set the env variables as described in that link with no luck. Then I ran node-pre-gyp manually in node_modules\grpc like this:

node-pre-gyp install --target=1.4.15 --runtime=electron --update-binary

The output I get is:

node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.6.34
node-pre-gyp info using node@6.10.1 | win32 | x64
node-pre-gyp http GET https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.1.0/electron-v1.4-win32-x64.tar.gz
node-pre-gyp http 200 https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.1.0/electron-v1.4-win32-x64.tar.gz
node-pre-gyp info install unpacking grpc_node.node
node-pre-gyp info tarball done parsing tarball
node-pre-gyp info validate Running test command: 'C:\Program Files\nodejs\node.exe --eval 'require('D:/test_app/node_modules/grpc/src/node/extension_binary/grpc_node.node')''
[grpc] Success: "D:\test_app\node_modules\grpc\src\node\extension_binary\grpc_node.node" is installed via remote

I wonder what version of electron is that grpc binary compiled for.

If I had ran "npm install" without the right env variables, npm would have installed the pure node version of the precompiled binary and electron wouldn't have even loaded the module (require('grpc')) in the first place.

Either setting the env variables or running node-pre-gyp manually, it seems I do get a binary for electron but not the right one because require('grpc') works but it crashes after calling a function of my service. And as I said previsouly, the message gets successfully to my c++ grpc server but the response seems to break electron somehow.

@murgatroid99
Copy link
Member

The binary is built against electron 1.4.0. But I wouldn't expect that to be a problem; I'd be surprised if electron has binary incompatibility within a single minor version.

Do you have any more details about the crash?

It might be worth trying gRPC 1.2. There was at least one electron-related fix that I made since 1.1.0.

@andresiraola
Copy link
Author

andresiraola commented Apr 5, 2017

I ran more tests:

  1. I downgraded my project's electron to 1.4.0 and tried with the precompiled binary.

Same issue: the module can be loaded using require but it seems to crash when it receives the response. When I say crash I mean that the electron's renderer process dies and the devtools window shows the regular "DevTools was disconnected from the page"

  1. I built grpc 1.1.0 for electron 1.4.0 using electron-rebuild (and the fix of my first post) and worked as expected.

  2. I attached the VS debugger to electron while using my grpc build and could debug the function call and response. No issues here.

  3. I tried to debug the precompiled grpc module and wasn't able to attach to it. Well you know what I mean, I could attach to the process but my breakpoints weren't hit because clearly my symbols don't match the precompile binary. This somehow proves that the binary you can build from the grpc module is not the same as the precompiled one.

  4. Finally I upgraded grpc to 1.2.0 and good news! The precompiled binary works! This tells me that my code is ok and there is something going on with the grpc 1.1.0' precompiled binary for electron 1.4.x

I will update my project to use grpc 1.2.0 and go on working but anyway I think the build issue (gyp adding quotes to the echo warning) should be addressed.

@murgatroid99
Copy link
Member

This does not seem to have recurred in over a year.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants