Skip to content

Commit

Permalink
fix: Incorrect detection of open ZLIB handles (#12022)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliversalzburg committed Nov 2, 2021
1 parent 10d9580 commit 6114232
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@
### Fixes

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

Expand Down
15 changes: 15 additions & 0 deletions packages/jest-core/src/__tests__/collectHandles.test.js
Expand Up @@ -9,6 +9,7 @@
import {promises as dns} from 'dns';
import http from 'http';
import {PerformanceObserver} from 'perf_hooks';
import zlib from 'zlib';
import collectHandles from '../collectHandles';

describe('collectHandles', () => {
Expand Down Expand Up @@ -52,6 +53,20 @@ describe('collectHandles', () => {
);
});

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

const decompressed = zlib.inflateRawSync(
Buffer.from('cb2a2d2e5128492d2ec9cc4b0700', 'hex'),
);

const openHandles = await handleCollector();

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

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
Expand Up @@ -71,7 +71,8 @@ export default function collectHandles(): HandleCollectionResult {
type === 'ELDHISTOGRAM' ||
type === 'PerformanceObserver' ||
type === 'RANDOMBYTESREQUEST' ||
type === 'DNSCHANNEL'
type === 'DNSCHANNEL' ||
type === 'ZLIB'
) {
return;
}
Expand Down

0 comments on commit 6114232

Please sign in to comment.