Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: SIGNREQUEST incorrectly detected as an open handle #12775

@cristianrgreco

Description

@cristianrgreco

Version

28.0.3

Steps to reproduce

Run the following test via jest --detectOpenHandles:

const crypto = require('crypto');

test('should not detect open handles', () => {
  const key =
    '-----BEGIN PRIVATE KEY-----\r\nMC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD'
    + '/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r\n-----END PRIVATE KEY-----';

  const data = Buffer.from('a');

  const sig = crypto.sign(null, data, key);
});

Expected behavior

crypto.sign is a synchronous operation. Once the test completes, I would expect Jest to not detect any open handles.

Actual behavior

An open handle is detected:

> jest "--detectOpenHandles"

 PASS  ./test.js
  ✓ should not detect open handles (2 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        0.12 s, estimated 1 s
Ran all test suites.

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

  ●  SIGNREQUEST

       8 |   const data = Buffer.from('a');
       9 |
    > 10 |   const sig = crypto.sign(null, data, key);
         |                      ^
      11 | });
      12 |
      13 |

      at Object.sign (test.js:10:22)
      at TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:317:13)
      at runJest (node_modules/@jest/core/build/runJest.js:407:19)
      at _run10000 (node_modules/@jest/core/build/cli/index.js:338:7)
      at runCLI (node_modules/@jest/core/build/cli/index.js:190:3)

Additional context

No response

Environment

System:
  OS: Mac OS X 12.3.1 (21E258) / Ubuntu 20.04.4 LTS
  CPU: Apple M1 Max
Binaries:
  Node: v16.13.1 / v17.3.0
  NPM: 8.1.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions