Only use node-red audit events to update local package list #3189
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes how we track what additional modules have been installed in Node-RED.
When this was originally added, it was done in response to Node-RED writing its settings to the database - which includes a list of modules it has loaded.
We then added the ability to do this by listening to the audit events that get sent (
nodes.install
for eg).We have found a flaw in the logic of the first approach when a module is removed. There is a sequence where Node-RED rewrites its settings before it discovers the removed module is gone - causing the module to get added back to the package list.
On review, I've determined we don't need to rely on this mechanism - we can base it entirely on the audit events. So this PR removes this first mechanism.
Whilst there, I've also added support for the
modules.install
event that was added in Node-RED 3.1.1 - this is triggered when the Function node installs a module. This allows us to add those modules to the package list so they get reinstalled as part of the initial dependency install and not rely on Node-RED dynamically reinstalling them.