Skip to content

Commit

Permalink
fix: run GC before collecting open handles (#11278)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed May 20, 2021
1 parent 50451df commit 27bee72
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -70,6 +70,7 @@
- `[jest-core]` Don't report PerformanceObserver as open handle ([#11123](https://github.com/facebook/jest/pull/11123))
- `[jest-core]` Use `WeakRef` to hold timers when detecting open handles ([#11277](https://github.com/facebook/jest/pull/11277))
- `[jest-core]` Correctly detect open handles that were created in test functions using `done` callbacks ([#11382](https://github.com/facebook/jest/pull/11382))
- `[jest-core]` Do not collect `RANDOMBYTESREQUEST` as open handles ([#11278](https://github.com/facebook/jest/pull/11278))
- `[jest-diff]` [**BREAKING**] Use only named exports ([#11371](https://github.com/facebook/jest/pull/11371))
- `[jest-each]` [**BREAKING**] Ignore excess words in headings ([#8766](https://github.com/facebook/jest/pull/8766))
- `[jest-each]` Support array index with template strings ([#10763](https://github.com/facebook/jest/pull/10763))
Expand Down
11 changes: 11 additions & 0 deletions e2e/__tests__/detectOpenHandles.ts
Expand Up @@ -71,6 +71,17 @@ it('does not report promises', () => {
expect(textAfterTest).toBe('');
});

it('does not report crypto random data', () => {
// The test here is basically that it exits cleanly without reporting anything (does not need `until`)
const {stderr} = runJest('detect-open-handles', [
'crypto',
'--detectOpenHandles',
]);
const textAfterTest = getTextAfterTest(stderr);

expect(textAfterTest).toBe('');
});

onNodeVersions('>=11.10.0', () => {
it('does not report ELD histograms', () => {
const {stderr} = runJest('detect-open-handles', [
Expand Down
13 changes: 13 additions & 0 deletions e2e/detect-open-handles/__tests__/crypto.js
@@ -0,0 +1,13 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

const {randomFillSync} = require('crypto');

test('randomFillSync()', () => {
const buf = Buffer.alloc(10);
randomFillSync(buf);
});
3 changes: 2 additions & 1 deletion packages/jest-core/src/collectHandles.ts
Expand Up @@ -63,7 +63,8 @@ export default function collectHandles(): HandleCollectionResult {
type === 'PROMISE' ||
type === 'TIMERWRAP' ||
type === 'ELDHISTOGRAM' ||
type === 'PerformanceObserver'
type === 'PerformanceObserver' ||
type === 'RANDOMBYTESREQUEST'
) {
return;
}
Expand Down

0 comments on commit 27bee72

Please sign in to comment.