Skip to content

Commit 27bee72

Browse files
authored
fix: run GC before collecting open handles (#11278)
1 parent 50451df commit 27bee72

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
- `[jest-core]` Don't report PerformanceObserver as open handle ([#11123](https://github.com/facebook/jest/pull/11123))
7171
- `[jest-core]` Use `WeakRef` to hold timers when detecting open handles ([#11277](https://github.com/facebook/jest/pull/11277))
7272
- `[jest-core]` Correctly detect open handles that were created in test functions using `done` callbacks ([#11382](https://github.com/facebook/jest/pull/11382))
73+
- `[jest-core]` Do not collect `RANDOMBYTESREQUEST` as open handles ([#11278](https://github.com/facebook/jest/pull/11278))
7374
- `[jest-diff]` [**BREAKING**] Use only named exports ([#11371](https://github.com/facebook/jest/pull/11371))
7475
- `[jest-each]` [**BREAKING**] Ignore excess words in headings ([#8766](https://github.com/facebook/jest/pull/8766))
7576
- `[jest-each]` Support array index with template strings ([#10763](https://github.com/facebook/jest/pull/10763))

e2e/__tests__/detectOpenHandles.ts

+11
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ it('does not report promises', () => {
7171
expect(textAfterTest).toBe('');
7272
});
7373

74+
it('does not report crypto random data', () => {
75+
// The test here is basically that it exits cleanly without reporting anything (does not need `until`)
76+
const {stderr} = runJest('detect-open-handles', [
77+
'crypto',
78+
'--detectOpenHandles',
79+
]);
80+
const textAfterTest = getTextAfterTest(stderr);
81+
82+
expect(textAfterTest).toBe('');
83+
});
84+
7485
onNodeVersions('>=11.10.0', () => {
7586
it('does not report ELD histograms', () => {
7687
const {stderr} = runJest('detect-open-handles', [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
const {randomFillSync} = require('crypto');
9+
10+
test('randomFillSync()', () => {
11+
const buf = Buffer.alloc(10);
12+
randomFillSync(buf);
13+
});

packages/jest-core/src/collectHandles.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ export default function collectHandles(): HandleCollectionResult {
6363
type === 'PROMISE' ||
6464
type === 'TIMERWRAP' ||
6565
type === 'ELDHISTOGRAM' ||
66-
type === 'PerformanceObserver'
66+
type === 'PerformanceObserver' ||
67+
type === 'RANDOMBYTESREQUEST'
6768
) {
6869
return;
6970
}

0 commit comments

Comments
 (0)