Skip to content

Commit 8522a55

Browse files
mrsharpobluntocpojer
authored andcommitted
Haste-map now cleans up workers if throwOnModuleCollision is set to true (jestjs#1916)
and a module collision occurs
1 parent 8af82e1 commit 8522a55

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

packages/jest-haste-map/src/index.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -354,18 +354,24 @@ class HasteMap {
354354
);
355355
}
356356

357+
const cleanup = () => {
358+
if (this._workerFarm) {
359+
workerFarm.end(this._workerFarm);
360+
}
361+
this._workerFarm = null;
362+
this._workerPromise = null;
363+
};
364+
357365
return Promise.all(promises)
358-
.then(() => {
359-
if (this._workerFarm) {
360-
workerFarm.end(this._workerFarm);
361-
}
362-
this._workerFarm = null;
363-
this._workerPromise = null;
364-
})
366+
.then(cleanup)
365367
.then(() => {
366368
hasteMap.map = map;
367369
hasteMap.mocks = mocks;
368370
return hasteMap;
371+
})
372+
.catch(err => {
373+
cleanup();
374+
return Promise.reject(err);
369375
});
370376
}
371377

0 commit comments

Comments
 (0)