1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #3999 from node-red/fix-plugin-async

Fix async loading of modules containing both nodes and plugins
This commit is contained in:
Nick O'Leary 2023-02-02 10:23:42 +00:00 committed by GitHub
commit 8382665bbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -126,38 +126,24 @@ function loadModuleFiles(modules) {
}
var pluginList;
var nodeList;
return Promise.all(pluginPromises).then(function(results) {
pluginList = results.filter(r => !!r);
// Initial plugin load has happened. Ensure modules that provide
// plugins are in the registry now.
for (var module in modules) {
if (modules.hasOwnProperty(module)) {
if (modules[module].plugins && Object.keys(modules[module].plugins).length > 0) {
// Add the modules for plugins
if (!modules[module].err) {
registry.addModule(modules[module]);
}
}
}
}
return loadNodeSetList(pluginList);
}).then(function() {
return Promise.all(nodePromises);
return Promise.all(nodePromises)
}).then(function(results) {
nodeList = results.filter(r => !!r);
// Initial node load has happened. Ensure remaining modules are in the registry
for (var module in modules) {
if (modules.hasOwnProperty(module)) {
if (!modules[module].plugins || Object.keys(modules[module].plugins).length === 0) {
if (!modules[module].err) {
registry.addModule(modules[module]);
}
if (!modules[module].err) {
registry.addModule(modules[module]);
}
}
}
}).then(function() {
return loadNodeSetList(pluginList);
}).then(function() {
return loadNodeSetList(nodeList);
});
})
}
async function loadPluginTemplate(plugin) {