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

fix: Incorrect detection of open ZLIB handles #12022

Merged
merged 1 commit into from Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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