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

crypto.generateKeyPairSync causing KEYPAIRGENREQUEST "potentially keeping Jest from exiting" #11754

Closed
hornta opened this issue Aug 15, 2021 · 5 comments

Comments

@hornta
Copy link

hornta commented Aug 15, 2021

🐛 Bug Report

Jest's --detectOpenHandles logic is getting triggered by calling crypto.generateKeyPairSync in a test. However it lets a node js program exit without any problems.

To Reproduce

Call this code in a jest test

require("crypto").generateKeyPairSync('ec', {
    namedCurve: 'sect239k1'
  });

and it produces:

Jest has detected the following 1 open handles potentially keeping Jest from exiting:

    KEYPAIRGENREQUEST

      66 |     }
      67 |
    > 68 |     const keyPair = crypto.generateKeyPairSync('ec', { namedCurve: 'P-256' })

Expected behavior

Should not trigger a warning.

Link to repl or repo (highly encouraged)

https://replit.com/@hornta/Jest-issue-with-cryptogenerateKeyPairSync#index.test.js

envinfo

  System:
    OS: Windows 10 10.0.19043
    CPU: (8) x64 Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
  Binaries:
    Node: 16.5.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 7.11.1 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    jest: ^27.0.6 => 27.0.6
@sigveio
Copy link
Contributor

sigveio commented Aug 18, 2021

I wasn't able to reproduce this with the LTS (14.x), but it does appear to happen with current (16.x) with both sync and async.

I see you switched to using js-crypto-ec for your project instead, which seems to use the ECDH class from Node's crypto. That works well across the board, so I'm mentioning it for anyone else who might run into the same issue.

If you would be willing to dive a bit deeper and try to figure out whats causing the problems with generateKeyPairSync (e.g. whether it's a bug in Jest or Node), the help would be appreciated and increase the likelihood of it being fixed. The open handles collection in core would probably be a good place to start. And from a quick search, it's also possible that for example #11464 and #11470 contains some relevant / useful clues.

@gnarea
Copy link

gnarea commented Jun 13, 2022

I can reproduce this issue with the latest version from master in this repo: https://github.com/relaycorp/relaynet-poweb-js

I can reliably reproduce it with Node.js 18 and Ubuntu 22.04. I've tried v14 but it works without issues there.

For some reason, I can't reproduce it in CI (with GitHub Actions).

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Jun 13, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 13, 2023
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 13, 2023
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

4 participants