Skip to content

Commit 6114232

Browse files
fix: Incorrect detection of open ZLIB handles (#12022)
1 parent 10d9580 commit 6114232

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
### Fixes
99

1010
- `[expect]` Allow again `expect.Matchers` generic with single value ([#11986](https://github.com/facebook/jest/pull/11986))
11+
- `[jest-core]` Incorrect detection of open ZLIB handles ([#12022](https://github.com/facebook/jest/pull/12022))
1112
- `[jest-environment-jsdom]` Add `@types/jsdom` dependency ([#11999](https://github.com/facebook/jest/pull/11999))
1213
- `[jest-transform]` Improve error and warning messages ([#11998](https://github.com/facebook/jest/pull/11998))
1314

packages/jest-core/src/__tests__/collectHandles.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import {promises as dns} from 'dns';
1010
import http from 'http';
1111
import {PerformanceObserver} from 'perf_hooks';
12+
import zlib from 'zlib';
1213
import collectHandles from '../collectHandles';
1314

1415
describe('collectHandles', () => {
@@ -52,6 +53,20 @@ describe('collectHandles', () => {
5253
);
5354
});
5455

56+
it('should not collect the ZLIB open handle', async () => {
57+
const handleCollector = collectHandles();
58+
59+
const decompressed = zlib.inflateRawSync(
60+
Buffer.from('cb2a2d2e5128492d2ec9cc4b0700', 'hex'),
61+
);
62+
63+
const openHandles = await handleCollector();
64+
65+
expect(openHandles).not.toContainEqual(
66+
expect.objectContaining({message: 'ZLIB'}),
67+
);
68+
});
69+
5570
it('should collect handles opened in test functions with `done` callbacks', done => {
5671
const handleCollector = collectHandles();
5772
const server = http.createServer((_, response) => response.end('ok'));

packages/jest-core/src/collectHandles.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ export default function collectHandles(): HandleCollectionResult {
7171
type === 'ELDHISTOGRAM' ||
7272
type === 'PerformanceObserver' ||
7373
type === 'RANDOMBYTESREQUEST' ||
74-
type === 'DNSCHANNEL'
74+
type === 'DNSCHANNEL' ||
75+
type === 'ZLIB'
7576
) {
7677
return;
7778
}

0 commit comments

Comments
 (0)