Web3.js: Update websocket fork (node-gyp err output on Windows / Node 12)

Created on 10 Feb 2020  路  16Comments  路  Source: ChainSafe/web3.js

Expected behavior

npm install command is executed without errors

Actual behavior

npm install shows errors

Steps to reproduce the behavior

  1. npm init
  2. npm install web 3

Logs

@web3-js/[email protected] install C:\Temp\web3.test\node_modules\@web3-js\websocket
(node-gyp rebuild 2> builderror.log) || (exit 0)

C:\Temp\web3.test\node_modules\@web3-js\websocket>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
bufferutil.cc
win_delay_load_hook.cc
C:\Temp\web3.test\node_modules\@web3-js\websocket\src\bufferutil.cc(34,1): error C2660: 'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\bufferutil.vcxproj]
C:\Users\dummyuser\AppData\Local\node-gypCache\12.14.1\include\node\v8.h(5995,46): message : see declaration of 'v8::FunctionTemplate::GetFunction' (compiling source file ..\src\bufferutil.cc) [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\bufferutil.vcxproj]
C:\Temp\web3.test\node_modules\@web3-js\websocket\src\bufferutil.cc(34,1): error C2661: 'Nan::Set': no overloaded function takes 2 arguments [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\bufferutil.vcxproj]
C:\Temp\web3.test\node_modules\@web3-js\websocket\src\bufferutil.cc(50,1): error C2661: 'v8::Value::ToObject': no overloaded function takes 0 arguments [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\bufferutil.vcxproj]
C:\Temp\web3.test\node_modules\@web3-js\websocket\src\bufferutil.cc(57,1): error C2661: 'v8::Value::ToObject': no overloaded function takes 0 arguments [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\bufferutil.vcxproj]
C:\Temp\web3.test\node_modules\@web3-js\websocket\src\bufferutil.cc(68,1): error C2661: 'v8::Value::ToObject': no overloaded function takes 0 arguments [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\bufferutil.vcxproj]
C:\Temp\web3.test\node_modules\@web3-js\websocket\src\bufferutil.cc(70,1): error C2661: 'v8::Value::ToObject': no overloaded function takes 0 arguments [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\bufferutil.vcxproj]
C:\Temp\web3.test\node_modules\@web3-js\websocket\src\bufferutil.cc(89,1): error C2661: 'v8::Value::ToObject': no overloaded function takes 0 arguments [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\bufferutil.vcxproj]
C:\Temp\web3.test\node_modules\@web3-js\websocket\src\bufferutil.cc(90,1): error C2661: 'v8::Value::ToObject': no overloaded function takes 0 arguments [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\bufferutil.vcxproj]
C:\Temp\web3.test\node_modules\@web3-js\websocket\src\bufferutil.cc(92,1): error C2661: 'v8::Value::ToObject': no overloaded function takes 0 arguments [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\bufferutil.vcxproj]
C:\Temp\web3.test\node_modules\@web3-js\websocket\src\bufferutil.cc(93,1): error C2660: 'v8::Value::Int32Value': function does not take 0 arguments [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\bufferutil.vcxproj]
C:\Users\dummyuser\AppData\Local\node-gypCache\12.14.1\include\node\v8.h(2613,40): message : see declaration of 'v8::Value::Int32Value' (compiling source file ..\src\bufferutil.cc) [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\bufferutil.vcxproj]
C:\Temp\web3.test\node_modules\@web3-js\websocket\src\bufferutil.cc(94,1): error C2660: 'v8::Value::Int32Value': function does not take 0 arguments [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\bufferutil.vcxproj]
C:\Users\dummyuser\AppData\Local\node-gypCache\12.14.1\include\node\v8.h(2613,40): message : see declaration of 'v8::Value::Int32Value' (compiling source file ..\src\bufferutil.cc) [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\bufferutil.vcxproj]
validation.cc
win_delay_load_hook.cc
C:\Temp\web3.test\node_modules\@web3-js\websocket\src\validation.cc(114,1): error C2660: 'v8::FunctionTemplate::GetFunction': function does not take 0 arguments [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\validation.vcxproj]
C:\Users\dummyuser\AppData\Local\node-gypCache\12.14.1\include\node\v8.h(5995,46): message : see declaration of 'v8::FunctionTemplate::GetFunction' (compiling source file ..\src\validation.cc) [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\validation.vcxproj]
C:\Temp\web3.test\node_modules\@web3-js\websocket\src\validation.cc(114,1): error C2661: 'Nan::Set': no overloaded function takes 2 arguments [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\validation.vcxproj]
C:\Temp\web3.test\node_modules\@web3-js\websocket\src\validation.cc(133,1): error C2661: 'v8::Value::ToObject': no overloaded function takes 0 arguments [C:\Temp\web3.test\node_modules\@web3-js\websocketbuild\validation.vcxproj]

Versions

[NPM, Node, Web3.js, OS, device...]
OS: Win 10, desktop
Node: v12.14.1
Npm: 6.13.4

1.x dependencies

Most helpful comment

@user535353 Have reproduced the error you're seeing in a Windows 10 / Node 12 container on Travis. It only appears in the Windows node-gyp output, Linux and OSX are clean.

Additionally, Web3 installs without obvious problems in the test. NPM completes successfully, and the lib is able to open a Websocket connection to Infura / fetch a block. So this doesn't look critical - e.g Windows / Node 12 users are able to install.

That said we will need to pull in patches from web3-js/websocket's parent fork as part of basic 1.x maintenance and this should be part of it.

All 16 comments

@user535353

I see web3 installing successfully in CI on Node 12.13 / Ubuntu Xenial here.

Could you see if your error persists when moving down to a slightly lower Node version? This might help to isolate the problem.

There's also a guide to Window's specific node-gyp problems here that might be useful for debugging. Could you go through that list and see if any of the suggestions resolve this for you?

For clarity - could you also list which version of Web3 you're installing?

For clarity - could you also list which version of Web3 you're installing?
just 'npm install web3'
package.json after that:
"dependencies": {
"web3": "^1.2.6"
}

with node v11.15.0:

C:\Temp\web3.test\node_modules\keccak>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Program Files\Python38\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:299:12)
gyp ERR! stack at ChildProcess.emit (events.js:193:13)
gyp ERR! stack at maybeClose (internal/child_process.js:999:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:266:5)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Temp\web3.test\node_modules\keccak
gyp ERR! node -v v11.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] rebuild: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\dummyuser\AppData\Roaming\npm-cache_logs\2020-02-11T18_25_14_927Z-debug.log
"Keccak bindings compilation fail. Pure JS implementation will be used."

[email protected] install C:\Temp\web3.test\node_modules\secp256k1
npm run rebuild || echo "Secp256k1 bindings compilation fail. Pure JS implementation will be used."

@user535353 Have you looked at the windows guide referenced above? Do you have windows-build-tools installed as advised there?

Seems, the websocket is just incompatible with most recent node.
For instance it uses 't->GetFunction()' without a parameter, but the latest version of v8 has the following definition (with a parameter):

/* Returns the unique function instance in the current execution context./
V8_WARN_UNUSED_RESULT MaybeLocal GetFunction(
Local context);

So there is a number of errors when trying to build the websocket project:
image

So, seems, the websocket dependency needs to be updated.

@user535353 Thanks for investigating and for those links.

I'm not able to reproduce this failure for Web3 1.2.6 on either 12.14.1 or 12.16.0. Tried:

  • locally, (Mac OSX) Node (npm install --save web3)
  • on Travis (Ubuntu / Xenial) (from git clone ) (see here)

Will see if I can get a Windows job running in CI to discover if this problem is Windows specific.

@cgewecke Is there any reason to depend on '@web3-js/websocket' instead of 'websocket'?

npm install websocket - gives 1.0.31 and no errors

npm install @web3-js/websocket - gives 1.0.30 and errors

@user535353

npm install websocket - gives 1.0.31 and no errors

Agree this would be the ideal solution. Would also like to be able to reproduce the error.

The origins of the Websocket fork are in:

Great they probably did improve the detection of the global object as well. Can you verify that those changes are applied @cgewecke?

Edit:
We probably have to update our fork and to publish a new version with the node-gyp fix.

@user535353

Out of curiosity - does the installation succeed for you or not?

Was able to reproduce the output you posted above in this Travis CI job (Windows / Node 12.16.0 ), but installation appears to ok there. (Maybe superficially). Npm install exits 0.

Node-gyp isn't throwing a fatal error.

@user535353 Have reproduced the error you're seeing in a Windows 10 / Node 12 container on Travis. It only appears in the Windows node-gyp output, Linux and OSX are clean.

Additionally, Web3 installs without obvious problems in the test. NPM completes successfully, and the lib is able to open a Websocket connection to Infura / fetch a block. So this doesn't look critical - e.g Windows / Node 12 users are able to install.

That said we will need to pull in patches from web3-js/websocket's parent fork as part of basic 1.x maintenance and this should be part of it.

same errors (Windows 10/Node 12.13.0). any progress for this issue?

This issue was fixed in Websocket 1.0.31, but web3's fork did not keep up with that change.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

webersson picture webersson  路  3Comments

ragnu picture ragnu  路  3Comments

zamoore picture zamoore  路  3Comments

sundbry picture sundbry  路  3Comments

connectdotz picture connectdotz  路  3Comments