Skip to content

Commit 4cae680

Browse files
authored
Ignore DNSCHANNEL when using --detectOpenHandles (#11470)
1 parent 8b0a342 commit 4cae680

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Fixes
1010

1111
- `[jest-circus, @jest/test-sequencer]` Remove dependency on `jest-runner` ([#11466](https://github.com/facebook/jest/pull/11466))
12+
- `[jest-core]` Do not warn about `DNSCHANNEL` handles when using the `--detectOpenHandles` option ([#11470](https://github.com/facebook/jest/pull/11470))
1213
- `[jest-runner]` Remove dependency on `jest-config` ([#11466](https://github.com/facebook/jest/pull/11466))
1314
- `[jest-worker]` Loosen engine requirement to `>= 10.13.0` ([#11451](https://github.com/facebook/jest/pull/11451))
1415

e2e/__tests__/__snapshots__/detectOpenHandles.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This usually means that there are asynchronous operations that weren't stopped i
1313
exports[`prints out info about open handlers 1`] = `
1414
Jest has detected the following 1 open handle potentially keeping Jest from exiting:
1515
16-
DNSCHANNEL
16+
TCPSERVERWRAP
1717
1818
12 | const app = new Server();
1919
13 |

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

+14
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*
77
*/
88

9+
import {promises as dns} from 'dns';
910
import http from 'http';
1011
import {PerformanceObserver} from 'perf_hooks';
1112
import collectHandles from '../collectHandles';
@@ -38,6 +39,19 @@ describe('collectHandles', () => {
3839
obs.disconnect();
3940
});
4041

42+
it('should not collect the DNSCHANNEL open handle', async () => {
43+
const handleCollector = collectHandles();
44+
45+
const resolver = new dns.Resolver();
46+
resolver.getServers();
47+
48+
const openHandles = await handleCollector();
49+
50+
expect(openHandles).not.toContainEqual(
51+
expect.objectContaining({message: 'DNSCHANNEL'}),
52+
);
53+
});
54+
4155
it('should collect handles opened in test functions with `done` callbacks', done => {
4256
const handleCollector = collectHandles();
4357
const server = http.createServer((_, response) => response.end('ok'));

packages/jest-core/src/collectHandles.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,16 @@ export default function collectHandles(): HandleCollectionResult {
6262
triggerAsyncId,
6363
resource: {} | NodeJS.Timeout,
6464
) {
65+
// Skip resources that should not generally prevent the process from
66+
// exiting, not last a meaningfully long time, or otherwise shouldn't be
67+
// tracked.
6568
if (
6669
type === 'PROMISE' ||
6770
type === 'TIMERWRAP' ||
6871
type === 'ELDHISTOGRAM' ||
6972
type === 'PerformanceObserver' ||
70-
type === 'RANDOMBYTESREQUEST'
73+
type === 'RANDOMBYTESREQUEST' ||
74+
type === 'DNSCHANNEL'
7175
) {
7276
return;
7377
}

0 commit comments

Comments
 (0)