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

yarn add hangs on Electron 12.1/Node 14.16.0 #646

Closed
DiefBell opened this issue Aug 21, 2024 · 19 comments · Fixed by #648
Closed

yarn add hangs on Electron 12.1/Node 14.16.0 #646

DiefBell opened this issue Aug 21, 2024 · 19 comments · Fixed by #648

Comments

@DiefBell
Copy link
Contributor

Describe the bug

When running yarn add [email protected] in my Electron 12.1 (Node 14.16.0) project at the lines:

[-/16] waiting...
[16/16] zeromq

I've left this for over two hours so I'm fairly sure it's not just being slow

Reproducing

  1. Have an Electron 12.1 project
  2. Run yarn add [email protected]

Expected behavior
It installs fine

Tested on

  • OS: Windows 11
  • ZeroMQ.js version: 6.0.0
  • Electron version: 12.1.0
  • Node version: 14.16.0
  • Yarn version: 1.22.11
@DiefBell DiefBell added the bug label Aug 21, 2024
@DiefBell
Copy link
Contributor Author

Update: this is working fine for some others in my organisation, will continue to investigate

@aminya
Copy link
Member

aminya commented Aug 21, 2024

Is it an X64 Windows 11? Have you tried with other package managers?

@DiefBell
Copy link
Contributor Author

Yes x64, I'll give it a go with NPM

@DiefBell
Copy link
Contributor Author

Same issues with NPM

@DiefBell
Copy link
Contributor Author

Has this been tested on lower NodeJS versions, down to the claimed minimum of Node 10.2? Because execa imports a lot of things with the node: prefix, which I believe is only available for Node >= 16.0.0. We're on Node 14

@aminya
Copy link
Member

aminya commented Aug 22, 2024

The build should not be triggered normally because we provide prebuilds, and if it is triggered, it should be compatible as we only use shelljs.
https://github.com/zeromq/zeromq.js/blob/master/script/build.ts

Have you tried passing --verbose to npm or yarn to get more logs? It's hard to say what is happening.

@DiefBell
Copy link
Contributor Author

Yes, we get verbose output right up until that build step

@aminya
Copy link
Member

aminya commented Aug 22, 2024

Try this in Pwsh:

mkdir ./zeromq-test
cd ./zeromq-test
$zeromq_pkg=$(npm view zeromq dist.tarball)
curl -LJO "$zeromq_pkg"
tar -xvf ./zeromq-6.0.0.tgz
cd ./package
npm i --verbose

You can play with "install": "(npm run build.js || echo ok) && aminya-node-gyp-build --build-from-source --verbose", in package.json to see what is happening.

@aminya
Copy link
Member

aminya commented Aug 22, 2024

Trying this with npm I realized that process.env.npm_config_argv is not defined in npm 10 resulting in this always returning false! The fix would be to patch node-gyp-build. These kinds of issues are the reason I needed to fork this unreliable package.

https://github.com/prebuild/node-gyp-build/blob/464e3881600de2107f35fd1c55afff232a768123/bin.js#L75

The same thing worked with pnpm

@DiefBell
Copy link
Contributor Author

I'm using yarn 1.11, so is it failing for the same reason as with NPM 10?

@DiefBell
Copy link
Contributor Author

Ah I see, this line https://github.com/prebuild/node-gyp-build/blob/464e3881600de2107f35fd1c55afff232a768123/bin.js#L75 always being false means that there is never any verbose logging?

@aminya
Copy link
Member

aminya commented Aug 22, 2024

Please try 6.0.1 and see if you still see the issue.

@DiefBell
Copy link
Contributor Author

It now fails to build, but does so silently. However, --verbose is now giving information. It has failed with the following error:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\ProgramData\\nvm\\nodejs\\node.exe',
1 verbose cli   'C:\\ProgramData\\nvm\\v14.16.0\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build.script'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild.script', 'build.script', 'postbuild.script' ]
5 info lifecycle [email protected]~prebuild.script: [email protected]
6 info lifecycle [email protected]~build.script: [email protected]
7 verbose lifecycle [email protected]~build.script: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~build.script: PATH: redacted
9 verbose lifecycle [email protected]~build.script: CWD: C:\SOURCE FOLDER\node_modules\zeromq
10 silly lifecycle [email protected]~build.script: Args: [
10 silly lifecycle   '/d /s /c',
10 silly lifecycle   'tsc -p ./script/tsconfig.esm.json && tsc -p ./script/tsconfig.json'
10 silly lifecycle ]
11 silly lifecycle [email protected]~build.script: Returned: code: 2  signal: null
12 info lifecycle [email protected]~build.script: Failed to exec build.script script
13 verbose stack Error: [email protected] build.script: `tsc -p ./script/tsconfig.esm.json && tsc -p ./script/tsconfig.json`
13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> (C:\ProgramData\nvm\v14.16.0\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\ProgramData\nvm\v14.16.0\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1048:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid [email protected]
15 verbose cwd C:\SOURCEFOLDER\node_modules\zeromq
16 verbose Windows_NT 10.0.22631
17 verbose argv "C:\\ProgramData\\nvm\\nodejs\\node.exe" "C:\\ProgramData\\nvm\\v14.16.0\\node_modules\\npm\\bin\\npm-cli.js" "run" "build.script"
18 verbose node v14.16.0
19 verbose npm  v6.14.11
20 error code ELIFECYCLE
21 error errno 2
22 error [email protected] build.script: `tsc -p ./script/tsconfig.esm.json && tsc -p ./script/tsconfig.json`
22 error Exit status 2
23 error Failed at the [email protected] build.script script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

We've forked the zmqjs repo to try to build it ourselves, but can't with Node 14.16.0 but can with Node 16.17.1 (but we're stuck on 14 for now.

One cause of this could be that [email protected] requires Node APIs with the node: prefix, which isn't available before Node 16. [email protected] is that last version to node use the node: prefix.

@DiefBell
Copy link
Contributor Author

There's also a regression in [email protected] such that spaces in the path to Node (e.g. "C:\Program Files") fails. Think that may be in your fork also

@aminya
Copy link
Member

aminya commented Aug 23, 2024

Please try 6.0.3 and check if you still see the issue.

@DiefBell
Copy link
Contributor Author

Can't test just yet, but some of those package.json scripts look like they might only work on a Bash/zsh terminal?

@aminya
Copy link
Member

aminya commented Aug 23, 2024

All the scripts are cross-platform and are tested in GitHub Actions. Which specific script are you talking about?

@DiefBell
Copy link
Contributor Author

Can confirm that this has fixed the issue, thanks!

@aminya
Copy link
Member

aminya commented Aug 28, 2024

Great. You're welcome

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

Successfully merging a pull request may close this issue.

2 participants