Best-effort fix for crash
Summary: The keys in WeakMaps have to be Objects (i.e. can't be primitives) as they have to be fall under the responsibility of the GC. Without this check, we may get "TypeError: Invalid value used as weak map key" as we accept `any` as `data` for the inspector. I'm not entirely confident if this check is enough, but I also don't have a way of reproducing the error we got reported. Reviewed By: jknoxville Differential Revision: D14182463 fbshipit-source-id: 3397678935f08513e485bf5654377b54053ee32f
This commit is contained in:
committed by
Facebook Github Bot
parent
156a0c17c6
commit
2a94da7db3
@@ -203,7 +203,15 @@ function getRootContextMenu(data: Object): Array<Electron$MenuItemOptions> {
|
||||
},
|
||||
},
|
||||
];
|
||||
rootContextMenuCache.set(data, menu);
|
||||
if (data instanceof Object) {
|
||||
rootContextMenuCache.set(data, menu);
|
||||
} else {
|
||||
console.error(
|
||||
'[data-inspector] Ignoring unsupported data type for cache: ',
|
||||
data,
|
||||
typeof data,
|
||||
);
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user