Skip to content

Commit

Permalink
Workaround a node >=12.5.0 bug that causes the process not to exit af…
Browse files Browse the repository at this point in the history
…ter tests have completed and cancerous memory growth (#8787)
  • Loading branch information
niieani authored and scotthovestadt committed Aug 16, 2019
1 parent 4df0070 commit 9ad0f4b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- `[jest-snapshots]` Fix test retries that contain snapshots ([#8629](https://github.com/facebook/jest/pull/8629))
- `[jest-mock]` Fix incorrect assignments when restoring mocks in instances where they originally didn't exist ([#8631](https://github.com/facebook/jest/pull/8631))
- `[expect]` Fix stack overflow when matching objects with circular references ([#8687](https://github.com/facebook/jest/pull/8687))
- `[jest-haste-map]` Workaround a node >=12.5.0 bug that causes the process not to exit after tests have completed and cancerous memory growth ([#8787](https://github.com/facebook/jest/pull/8787))

### Chore & Maintenance

Expand Down
24 changes: 13 additions & 11 deletions packages/jest-haste-map/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ class HasteMap extends EventEmitter {
.then(workerReply, workerError);
}

private async _buildHasteMap(data: {
private _buildHasteMap(data: {
removedFiles: FileData;
changedFiles?: FileData;
hasteMap: InternalHasteMap;
Expand Down Expand Up @@ -687,16 +687,18 @@ class HasteMap extends EventEmitter {
}
}

try {
await Promise.all(promises);
this._cleanup();
hasteMap.map = map;
hasteMap.mocks = mocks;
return hasteMap;
} catch (error) {
this._cleanup();
throw error;
}
return Promise.all(promises).then(
() => {
this._cleanup();
hasteMap.map = map;
hasteMap.mocks = mocks;
return hasteMap;
},
error => {
this._cleanup();
throw error;
},
);
}

private _cleanup() {
Expand Down

0 comments on commit 9ad0f4b

Please sign in to comment.