Skip to content

Commit

Permalink
Force haste map regeneration on deserialization error (#5642)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjesun authored and cpojer committed Feb 22, 2018
1 parent 52bbb26 commit cdd5dfe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/jest-haste-map/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,13 @@ class HasteMap extends EventEmitter {
* 1. read data from the cache or create an empty structure.
*/
read(): InternalHasteMap {
// This may throw. `_buildFileMap` will catch it and create a new map.
const hasteMap: InternalHasteMap = serializer.readFileSync(this._cachePath);
let hasteMap: InternalHasteMap;

try {
hasteMap = serializer.readFileSync(this._cachePath);
} catch (err) {
hasteMap = this._createEmptyMap();
}

for (const key in hasteMap) {
Object.setPrototypeOf(hasteMap[key], null);
Expand Down

0 comments on commit cdd5dfe

Please sign in to comment.