mirror of
https://github.com/Equicord/Equicord.git
synced 2025-07-01 17:34:24 -04:00
WebpackPatcher: Try catch more code prone to errors
This commit is contained in:
parent
98b1b11dfa
commit
707d688887
2 changed files with 49 additions and 19 deletions
|
@ -145,9 +145,17 @@ function makePropertyNonEnumerable(target: Record<PropertyKey, any>, key: Proper
|
|||
}
|
||||
|
||||
export function _blacklistBadModules(requireCache: NonNullable<AnyWebpackRequire["c"]>, exports: ModuleExports, moduleId: PropertyKey) {
|
||||
if (shouldIgnoreValue(exports)) {
|
||||
makePropertyNonEnumerable(requireCache, moduleId);
|
||||
return true;
|
||||
try {
|
||||
if (shouldIgnoreValue(exports)) {
|
||||
makePropertyNonEnumerable(requireCache, moduleId);
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
"Error while blacklisting module:\n", err,
|
||||
"\n\nModule id:", moduleId,
|
||||
"\n\nModule exports:", exports,
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof exports !== "object") {
|
||||
|
@ -156,17 +164,25 @@ export function _blacklistBadModules(requireCache: NonNullable<AnyWebpackRequire
|
|||
|
||||
let hasOnlyBadProperties = true;
|
||||
for (const exportKey in exports) {
|
||||
// Some exports might have not been initialized yet due to circular imports, so try catch it.
|
||||
try {
|
||||
var exportValue = exports[exportKey];
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
// Some exports might have not been initialized yet due to circular imports, so try catch it.
|
||||
try {
|
||||
var exportValue = exports[exportKey];
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (shouldIgnoreValue(exportValue)) {
|
||||
makePropertyNonEnumerable(exports, exportKey);
|
||||
} else {
|
||||
hasOnlyBadProperties = false;
|
||||
if (shouldIgnoreValue(exportValue)) {
|
||||
makePropertyNonEnumerable(exports, exportKey);
|
||||
} else {
|
||||
hasOnlyBadProperties = false;
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
"Error while blacklistng module:\n", err,
|
||||
"\n\nModule id:", moduleId,
|
||||
"\n\nExport value:", exportValue,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue