fix: only suppress module-not-found errors in plugin loader

Previously both loadOrchestrator() and loadPluginServices() caught all
errors, masking real failures like syntax errors or missing transitive
dependencies. Now only MODULE_NOT_FOUND / ERR_MODULE_NOT_FOUND errors
are suppressed; all other exceptions are rethrown.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
frostebite
2026-03-10 11:34:10 +00:00
parent 25f0a9c9f2
commit c91f9d16ee
3 changed files with 35 additions and 5 deletions
Generated Vendored
+16 -2
View File
@@ -2259,8 +2259,10 @@ async function loadOrchestrator() {
}, },
}; };
} }
catch { catch (error) {
// Orchestrator package not installed if (!isModuleNotFoundError(error)) {
throw error;
}
} }
} }
exports.loadOrchestrator = loadOrchestrator; exports.loadOrchestrator = loadOrchestrator;
@@ -2300,10 +2302,22 @@ async function loadPluginServices() {
}; };
} }
catch (error) { catch (error) {
if (!isModuleNotFoundError(error)) {
throw error;
}
core.warning(`Orchestrator plugin not available: ${error.message}`); core.warning(`Orchestrator plugin not available: ${error.message}`);
} }
} }
exports.loadPluginServices = loadPluginServices; exports.loadPluginServices = loadPluginServices;
function isModuleNotFoundError(error) {
if (error && typeof error === 'object' && 'code' in error) {
const code = error.code;
if (code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND') {
return true;
}
}
return typeof error?.message === 'string' && /cannot find module/i.test(error.message);
}
/***/ }), /***/ }),
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+18 -2
View File
@@ -30,8 +30,10 @@ export async function loadOrchestrator(): Promise<
}; };
}, },
}; };
} catch { } catch (error) {
// Orchestrator package not installed if (!isModuleNotFoundError(error)) {
throw error;
}
} }
} }
@@ -76,6 +78,20 @@ export async function loadPluginServices() {
}, },
}; };
} catch (error) { } catch (error) {
if (!isModuleNotFoundError(error)) {
throw error;
}
core.warning(`Orchestrator plugin not available: ${(error as Error).message}`); core.warning(`Orchestrator plugin not available: ${(error as Error).message}`);
} }
} }
function isModuleNotFoundError(error: unknown): boolean {
if (error && typeof error === 'object' && 'code' in error) {
const code = (error as { code: string }).code;
if (code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND') {
return true;
}
}
return typeof (error as Error)?.message === 'string' && /cannot find module/i.test((error as Error).message);
}