Thanks for your welcome message, and your swift reply, @marcus-j-davies !
This is definitely helpful, as you explain a possible flow to ensure work in the node continues only once the config node indicates it is ready.
With your approach, how does the config node come to life?
What might be special in our case: We have one global config, and the config is not part of the flow JSON.
Here is what we do: We use a hard-coded ID for the config node, and create the config node on demand (in onadd
), basically we do this:
RED.nodes.registerType('my-type', {
category: 'My Category',
...
onadd: function() {
let configExists = false;
RED.nodes.eachConfig(function (n) {
if (n.id === 'global-config-id') {
configExists = true;
}
});
if (!configExists) {
RED.nodes.add({
id: 'global-config-id',
type: 'my-config-type',
...
});
RED.nodes.dirty(true);
}
})
});
This means, when importing a flow that needs the global config, in a pristine environment, the config node never gets created, so deploying the flow crashes (as the config is expected to exist).
Is there a better way how to instantiate global config on demand, in such a way that it also works for importing a flow (through JSON or otherwise)?
On a side note: It may be good for us to migrate to a scenario without a global config (and without hard-coded ID) eventually, similar to this description. This would however not solve our immediate problem, I think.