From 9ea5e66a2a81d88e14bb23a319fe496e2782793b Mon Sep 17 00:00:00 2001 From: Miguel Jimenez Esun Date: Thu, 22 Feb 2018 23:09:12 +0000 Subject: [PATCH] Force haste map regeneration on deserialization error --- packages/jest-haste-map/src/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/jest-haste-map/src/index.js b/packages/jest-haste-map/src/index.js index 4af29b1c25ef..86c79cc6bd01 100644 --- a/packages/jest-haste-map/src/index.js +++ b/packages/jest-haste-map/src/index.js @@ -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);