node-red/node-red

runtime.isStarted returns true before flows are loaded

gavinhungry opened this issue · 2 comments

The start and stop methods for the runtime object set the value of started before the actual flows are started (or even loaded) or stopped. This results in isStarted returning true before the flows have even loaded.

The value should be set after the startFlows/stopFlows promises resolve to avoid this issue, unless there is a reason for it to behave this way?

runtime.start:
https://github.com/node-red/node-red/blob/0.13.4/red/runtime/index.js#L146,L147

runtime.stop:
https://github.com/node-red/node-red/blob/0.13.4/red/runtime/index.js#L179,L180

The runtime being started means it has completed loading the node definitions etc and is ready to start running a flow and processing runtime api requests. This is separate to the current flow running. For example, if the current flow requires a node that is not known to the runtime, it will block running the flow. However the api will be available to update the flow.

We have #698 open to add a suitable api for knowing the flow state.

Thanks @knolleary,

For my purposes, it suits to just listen for the nodes-started event for now.