mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 20:54:07 -08:00
refactor(core): Prevent community packages queries if feature is disabled (#6728)
This commit is contained in:
parent
eeb49e9375
commit
e1e6d4a749
|
@ -221,23 +221,6 @@ export class Start extends BaseCommand {
|
||||||
|
|
||||||
await this.loadNodesAndCredentials.generateTypesForFrontend();
|
await this.loadNodesAndCredentials.generateTypesForFrontend();
|
||||||
|
|
||||||
const installedPackages = await getAllInstalledPackages();
|
|
||||||
const missingPackages = new Set<{
|
|
||||||
packageName: string;
|
|
||||||
version: string;
|
|
||||||
}>();
|
|
||||||
installedPackages.forEach((installedPackage) => {
|
|
||||||
installedPackage.installedNodes.forEach((installedNode) => {
|
|
||||||
if (!this.loadNodesAndCredentials.known.nodes[installedNode.type]) {
|
|
||||||
// Leave the list ready for installing in case we need.
|
|
||||||
missingPackages.add({
|
|
||||||
packageName: installedPackage.packageName,
|
|
||||||
version: installedPackage.installedVersion,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
await UserSettings.getEncryptionKey();
|
await UserSettings.getEncryptionKey();
|
||||||
|
|
||||||
// Load settings from database and set them to config.
|
// Load settings from database and set them to config.
|
||||||
|
@ -246,36 +229,57 @@ export class Start extends BaseCommand {
|
||||||
config.set(setting.key, jsonParse(setting.value, { fallbackValue: setting.value }));
|
config.set(setting.key, jsonParse(setting.value, { fallbackValue: setting.value }));
|
||||||
});
|
});
|
||||||
|
|
||||||
config.set('nodes.packagesMissing', '');
|
const areCommunityPackagesEnabled = config.getEnv('nodes.communityPackages.enabled');
|
||||||
if (missingPackages.size) {
|
|
||||||
LoggerProxy.error(
|
|
||||||
'n8n detected that some packages are missing. For more information, visit https://docs.n8n.io/integrations/community-nodes/troubleshooting/',
|
|
||||||
);
|
|
||||||
|
|
||||||
if (flags.reinstallMissingPackages || process.env.N8N_REINSTALL_MISSING_PACKAGES) {
|
if (areCommunityPackagesEnabled) {
|
||||||
LoggerProxy.info('Attempting to reinstall missing packages', { missingPackages });
|
const installedPackages = await getAllInstalledPackages();
|
||||||
try {
|
const missingPackages = new Set<{
|
||||||
// Optimistic approach - stop if any installation fails
|
packageName: string;
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
version: string;
|
||||||
for (const missingPackage of missingPackages) {
|
}>();
|
||||||
await this.loadNodesAndCredentials.installNpmModule(
|
installedPackages.forEach((installedPackage) => {
|
||||||
missingPackage.packageName,
|
installedPackage.installedNodes.forEach((installedNode) => {
|
||||||
missingPackage.version,
|
if (!this.loadNodesAndCredentials.known.nodes[installedNode.type]) {
|
||||||
);
|
// Leave the list ready for installing in case we need.
|
||||||
missingPackages.delete(missingPackage);
|
missingPackages.add({
|
||||||
|
packageName: installedPackage.packageName,
|
||||||
|
version: installedPackage.installedVersion,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
LoggerProxy.info('Packages reinstalled successfully. Resuming regular initialization.');
|
});
|
||||||
} catch (error) {
|
});
|
||||||
LoggerProxy.error('n8n was unable to install the missing packages.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
config.set(
|
config.set('nodes.packagesMissing', '');
|
||||||
'nodes.packagesMissing',
|
if (missingPackages.size) {
|
||||||
Array.from(missingPackages)
|
LoggerProxy.error(
|
||||||
.map((missingPackage) => `${missingPackage.packageName}@${missingPackage.version}`)
|
'n8n detected that some packages are missing. For more information, visit https://docs.n8n.io/integrations/community-nodes/troubleshooting/',
|
||||||
.join(' '),
|
);
|
||||||
);
|
|
||||||
|
if (flags.reinstallMissingPackages || process.env.N8N_REINSTALL_MISSING_PACKAGES) {
|
||||||
|
LoggerProxy.info('Attempting to reinstall missing packages', { missingPackages });
|
||||||
|
try {
|
||||||
|
// Optimistic approach - stop if any installation fails
|
||||||
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
|
for (const missingPackage of missingPackages) {
|
||||||
|
await this.loadNodesAndCredentials.installNpmModule(
|
||||||
|
missingPackage.packageName,
|
||||||
|
missingPackage.version,
|
||||||
|
);
|
||||||
|
missingPackages.delete(missingPackage);
|
||||||
|
}
|
||||||
|
LoggerProxy.info('Packages reinstalled successfully. Resuming regular initialization.');
|
||||||
|
} catch (error) {
|
||||||
|
LoggerProxy.error('n8n was unable to install the missing packages.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config.set(
|
||||||
|
'nodes.packagesMissing',
|
||||||
|
Array.from(missingPackages)
|
||||||
|
.map((missingPackage) => `${missingPackage.packageName}@${missingPackage.version}`)
|
||||||
|
.join(' '),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const dbType = config.getEnv('database.type');
|
const dbType = config.getEnv('database.type');
|
||||||
|
|
Loading…
Reference in a new issue