Skip to content

Commit

Permalink
Do not collect SIGNREQUEST as open handles (jestjs#12789)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianrgreco authored May 2, 2022
1 parent 1dee273 commit 6a68a13
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Fixes

- `[@jest/expect-utils]` Fix deep equality of ImmutableJS Lists ([#12763](https://github.com/facebook/jest/pull/12763))
- `[jest-core]` Do not collect `SIGNREQUEST` as open handles ([#12789](https://github.com/facebook/jest/pull/12789))

### Chore & Maintenance

Expand Down
17 changes: 17 additions & 0 deletions packages/jest-core/src/__tests__/collectHandles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*
*/

import crypto from 'crypto';
import {promises as dns} from 'dns';
import http from 'http';
import {PerformanceObserver} from 'perf_hooks';
Expand Down Expand Up @@ -67,6 +68,22 @@ describe('collectHandles', () => {
);
});

it('should not collect the SIGNREQUEST open handle', async () => {
const handleCollector = collectHandles();

const key =
'-----BEGIN PRIVATE KEY-----\r\nMC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD' +
'/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r\n-----END PRIVATE KEY-----';
const data = Buffer.from('a');
crypto.sign(null, data, key);

const openHandles = await handleCollector();

expect(openHandles).not.toContainEqual(
expect.objectContaining({message: 'SIGNREQUEST'}),
);
});

it('should collect handles opened in test functions with `done` callbacks', done => {
const handleCollector = collectHandles();
const server = http.createServer((_, response) => response.end('ok'));
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-core/src/collectHandles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export default function collectHandles(): HandleCollectionResult {
type === 'PerformanceObserver' ||
type === 'RANDOMBYTESREQUEST' ||
type === 'DNSCHANNEL' ||
type === 'ZLIB'
type === 'ZLIB' ||
type === 'SIGNREQUEST'
) {
return;
}
Expand Down

0 comments on commit 6a68a13

Please sign in to comment.