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

Electron v6 and gRPC error #989

Closed
davidkell opened this issue Aug 8, 2019 · 17 comments
Closed

Electron v6 and gRPC error #989

davidkell opened this issue Aug 8, 2019 · 17 comments

Comments

@davidkell
Copy link

Problem description

We are unable to use gRPC with electron v6.

Reproduction steps

Start with an empty directory. Setup electron and grpc:

yarn add electron@6.0.1
yarn add grpc

Re-buliding grpc for electron returns an error:

npm rebuild --runtime=electron --target=6.0.1

Environment

  • macOS 10.14.5
  • v10.16.0
  • nvm
  • Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  • 1.22.2

Additional context

Traceback:

> electron@6.0.1 postinstall /Users/davidkell/dev/node_modules/electron
> node install.js


> grpc@1.22.2 install /Users/davidkell/dev/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library

node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://node-precompiled-binaries.grpc.io/grpc/v1.22.2/electron-v6.0-darwin-x64-unknown.tar.gz
node-pre-gyp WARN Pre-built binaries not found for grpc@1.22.2 and electron@6.0.1 (electron-v6.0 ABI, unknown) (falling back to source compile with node-gyp)
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: 404 response downloading https://nodejs.org/dist/v6.0.1/node-v6.0.1-headers.tar.gz
gyp ERR! stack     at Request.<anonymous> (/Users/davidkell/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:214:14)
gyp ERR! stack     at Request.emit (events.js:203:15)
gyp ERR! stack     at Request.onRequestResponse (/Users/davidkell/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/request/request.js:1066:10)
gyp ERR! stack     at ClientRequest.emit (events.js:198:13)
gyp ERR! stack     at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21)
gyp ERR! stack     at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
gyp ERR! stack     at TLSSocket.socketOnData (_http_client.js:442:20)
gyp ERR! stack     at TLSSocket.emit (events.js:198:13)
gyp ERR! stack     at addChunk (_stream_readable.js:288:12)
gyp ERR! stack     at readableAddChunk (_stream_readable.js:269:11)
gyp ERR! System Darwin 18.6.0
gyp ERR! command "/Users/davidkell/.nvm/versions/node/v10.16.0/bin/node" "/Users/davidkell/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--library=static_library" "--module=/Users/davidkell/dev/node_modules/grpc/src/node/extension_binary/electron-v6.0-darwin-x64-unknown/grpc_node.node" "--module_name=grpc_node" "--module_path=/Users/davidkell/dev/node_modules/grpc/src/node/extension_binary/electron-v6.0-darwin-x64-unknown" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=electron-v6.0"
gyp ERR! cwd /Users/davidkell/dev/node_modules/grpc
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/Users/davidkell/.nvm/versions/node/v10.16.0/bin/node /Users/davidkell/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/Users/davidkell/dev/node_modules/grpc/src/node/extension_binary/electron-v6.0-darwin-x64-unknown/grpc_node.node --module_name=grpc_node --module_path=/Users/davidkell/dev/node_modules/grpc/src/node/extension_binary/electron-v6.0-darwin-x64-unknown --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=electron-v6.0' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/davidkell/dev/node_modules/grpc/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:982:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
node-pre-gyp ERR! System Darwin 18.6.0
node-pre-gyp ERR! command "/Users/davidkell/.nvm/versions/node/v10.16.0/bin/node" "/Users/davidkell/dev/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd /Users/davidkell/dev/node_modules/grpc
node-pre-gyp ERR! node -v v10.16.0
node-pre-gyp ERR! node-pre-gyp -v v0.13.0
node-pre-gyp ERR! not ok
Failed to execute '/Users/davidkell/.nvm/versions/node/v10.16.0/bin/node /Users/davidkell/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/Users/davidkell/dev/node_modules/grpc/src/node/extension_binary/electron-v6.0-darwin-x64-unknown/grpc_node.node --module_name=grpc_node --module_path=/Users/davidkell/dev/node_modules/grpc/src/node/extension_binary/electron-v6.0-darwin-x64-unknown --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=electron-v6.0' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! grpc@1.22.2 install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the grpc@1.22.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/davidkell/.npm/_logs/2019-08-08T23_18_33_650Z-debug.log
@antho1404
Copy link

Got the same issue with similar versions.
Is there a workaround for that or any plan to fix this soon?

@murgatroid99
Copy link
Member

Version 1.23.0 is now out with Electron 6 support. Please try that version.

@antho1404
Copy link

it works perfectly, thanks :)

@davidkell
Copy link
Author

Fixed, thanks for that.

@felipemullen
Copy link

Version 1.23.0 is now out with Electron 6 support. Please try that version.

How can I run the proper commands? I've installed "grpc": "^1.23.3" and "electron": "^6.0.4" and I'm attempting to rebuild using

npm rebuild --runtime=electron --target=6.0.4

But I am not having any luck

@murgatroid99
Copy link
Member

How is it failing?

@felipemullen
Copy link

I'm on OSX 10.14.6

You can see at the start of the command that it tries to build using gRPC 1.22

MacBook-Pro-6:fmullen$ npm rebuild --runtime=electron --target=6.0.0

> electron@6.0.6 postinstall /Users/fmullen/code/megabot/node_modules/electron
> node install.js


> protobufjs@6.8.8 postinstall /Users/fmullen/code/megabot/node_modules/protobufjs
> node scripts/postinstall


> grpc@1.22.2 install /Users/fmullen/code/megabot/node_modules/@firebase/firestore/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library

node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(404): https://node-precompiled-binaries.grpc.io/grpc/v1.22.2/electron-v6.0-darwin-x64-unknown.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for grpc@1.22.2 and electron@6.0.0 (electron-v6.0 ABI, unknown) (falling back to source compile with node-gyp) 

[... lots of *.o files compiling]

In file included from ../deps/grpc/src/boringssl/err_data.c:18:
In file included from /Users/fmullen/Library/Caches/node-gyp/6.0.0/include/node/openssl/err.h:115:
/Users/fmullen/Library/Caches/node-gyp/6.0.0/include/node/openssl/e_os2.h:276:11: error: 'OPENSSL_EXPORT' macro redefined [-Werror,-Wmacro-redefined]
#  define OPENSSL_EXPORT extern

[... more errors]

There are about ~20 errors regarding macro redefined.
But I think I just need to somehow change to gRPC 1.23 as mentioned above. Just not sure how to do that.

I've deleted node_modules as well as package-lock.json but I am always seeing 1.22 used. Do I have to install 1.23 inside the electron folder?

@murgatroid99
Copy link
Member

npm rebuild doesn't install new versions of the library. You have to actually run npm install to get the new version.

@felipemullen
Copy link

Yes, that is correct. I can confirm that I have 1.23 listed in my package.json and this is still the behavior I see after running npm install. Is there something else I need to do in order to update the package?

@murgatroid99
Copy link
Member

What if you move the package.json file to a new directory and run npm install? What version of grpc do you get?

@felipemullen
Copy link

I think I found the issue. Even in a new directory, the script still ran with 1.22.2 so I cleaned out all other dependencies from package.json and started adding them back in one at a time.

The problem turned up again when I added firebase (needed for this project).

After upgrading from version 6.4.2 to the latest 6.5.0 the problem went away.
Hopefully this will help someone else.

Thanks for looking into it @murgatroid99

@felipemullen
Copy link

felipemullen commented Aug 30, 2019

for further reference, here is the offending section in package-lock.json

"@firebase/firestore": {
  "version": "1.5.0",
  "resolved": "https://registry.npmjs.org/@firebase/firestore/-/firestore-1.5.0.tgz",
  "integrity": "sha512-apZIwUWfWnIqoYD5QjpDKmZ9H5ghmT5wFJKMQsmniU+uQYaMo4CtQYcmw+WdvwAUXfqRBAaP0l/UErr4aqcn9w==",
  "requires": {
      "@firebase/firestore-types": "1.5.0",
      "@firebase/logger": "0.1.23",
      "@firebase/util": "0.2.26",
      "@firebase/webchannel-wrapper": "0.2.25",
      "@grpc/proto-loader": "^0.5.0",
      **"grpc": "1.22.2",**
      "tslib": "1.10.0"
    }
}

@nkndy
Copy link

nkndy commented Oct 22, 2019

Hi @felipemullen wondering which versions of Electron and firebase you are using for this. I am having the same issue. I have tried Electron v 6.0.11 & 6.1.0 & 7.0.0 along with Firebase 6.4.2 & 6.5.0 & 7.2.1

It looks like there has been some talk of this on the firebase js repo see:

firebase/firebase-js-sdk#1783

but for the time being the latest version of firebase's lockfile still looks like:
"@firebase/firestore@1.6.2": version "1.6.2" ... dependencies: "@firebase/firestore-types" "1.6.2" "@firebase/logger" "0.1.27" "@firebase/util" "0.2.30" "@firebase/webchannel-wrapper" "0.2.28" "@grpc/proto-loader" "^0.5.0" grpc "1.24.0" tslib "1.10.0"

@felipemullen
Copy link

felipemullen commented Oct 23, 2019

@nkndy these are the relevant versions listed in my package-lock file

    "electron": {
      "version": "6.0.6",
      "resolved": "https://registry.npmjs.org/electron/-/electron-6.0.6.tgz",
      ...
    },
    ...
    "firebase": {
      "version": "6.5.0",
      ...
      "requires": {
        "@firebase/app": "0.4.15",
        "@firebase/app-types": "0.4.3",
        "@firebase/auth": "0.11.8",
        "@firebase/database": "0.5.1",
        "@firebase/firestore": "1.5.0",
        "@firebase/functions": "0.4.16",
        "@firebase/installations": "0.2.5",
        "@firebase/messaging": "0.4.9",
        "@firebase/performance": "0.2.17",
        "@firebase/polyfill": "0.3.20",
        "@firebase/storage": "0.3.10",
        "@firebase/util": "0.2.26"
      }
    },
"@firebase/firestore": {
      "version": "1.5.0",
      ...
      "dependencies": {
        "grpc": {
          "version": "1.23.3",
          "resolved": "https://registry.npmjs.org/grpc/-/grpc-1.23.3.tgz",
          "integrity": "sha512-7vdzxPw9s5UYch4aUn4hyM5tMaouaxUUkwkgJlwbR4AXMxiYZJOv19N2ps2eKiuUbJovo5fnGF9hg/X91gWYjw==",
          "requires": {
            "@types/bytebuffer": "^5.0.40",
            "lodash.camelcase": "^4.3.0",
            "lodash.clone": "^4.5.0",
            "nan": "^2.13.2",
            "node-pre-gyp": "^0.13.0",
            "protobufjs": "^5.0.3"
          },
          ...
        }
      }
    },

I don't remember 100% but I may have actually edited the package-lock file manually in order to make this work. My statement about the upgrade making it work was a false positive, I just forgot to come back here and edit my comment.

That's why if you compare what I am currently using with my previous snippet, you will see that the old snippet lists firestore 1.5.0 with grpc 1.22.2 whereas the one here shows the same firestore with a newer grpc

@murgatroid99
Copy link
Member

I'm sorry, Electron 6 support got broken in grpc 1.24.0. But it is fixed in grpc 1.24.1

@Randyshu2018
Copy link

Version 1.23.0 is now out with Electron 6 support. Please try that version.

thank you for your advice and how about nested dependencies?

@felipemullen
Copy link

@Randyshu2018 if you are still having issues with nested dependencies (like firebase) you can try using the electron-rebuild package, it solved the issues for me without configuration changes.

I posted an answer here:
https://stackoverflow.com/questions/52156883/error-with-firebase-on-electron-app-failed-to-load-grpc/59299826#59299826

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

No branches or pull requests

6 participants