diff --git a/CHANGELOG.md b/CHANGELOG.md index 6283466826be..d77ce40779ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,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 diff --git a/packages/jest-haste-map/src/index.ts b/packages/jest-haste-map/src/index.ts index 70965909d79d..4a14bebc2eee 100644 --- a/packages/jest-haste-map/src/index.ts +++ b/packages/jest-haste-map/src/index.ts @@ -642,7 +642,7 @@ class HasteMap extends EventEmitter { .then(workerReply, workerError); } - private async _buildHasteMap(data: { + private _buildHasteMap(data: { removedFiles: FileData; changedFiles?: FileData; hasteMap: InternalHasteMap; @@ -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() {