noflo / noflo-ui

NoFlo Development Environment
https://app.flowhub.io
MIT License
767 stars 173 forks source link

component:getsource query does not wait for runtime:ports message #1019

Closed ERnsTL closed 3 years ago

ERnsTL commented 3 years ago

During the implementation of a new FBP network-protocol capable runtime (called flowd-rs, see Github, re-implementation of the previous flowd runtime), the following showed up:

Once enabling the capability component:getsource, the error message "Not permitted to send component:getsource messages" disappeared but there seems to be another problem to the error message "Unknown format for Rust graph Repeat" (may be a race condition or the payload attributes have the same names by bad luck):

Position of error message

The specification states there: "If the runtime is currently running a graph and it is able to speak the full Runtime protocol, it should follow up with a ports message."

"It should follow up with a ports message" seems to be interpreted that immediately after the runtime:runtime message, it should send a separate WebSocket message of type runtime:ports.

If this interpretation is correct, then noflo-ui does not wait for the follow-up runtime:ports message but proceeds to query the source code of the graph using a component:getsource message. But component:getsource only applies to components, not graphs?

Then it seems to get worse from there, I have attached the message exchange.

Bildschirmfoto von 2020-11-02 22-29-14

Maybe this is all just because the protocol implementation is being built up step by step

Implementation progression is as follows:

runtime:getruntime -> runtime:runtime + runtime:ports component:list -> component:component + component:componentsready network:getstatus -> network:status

Then noflo-ui complained that it is not allowed to request component:getsource, so I implemented it and allowed the capability.

component:getsource -> component:source

...but then noflo-ui immediately sends component:getsource for the graph name and disregards the follow-up runtime:ports message ... and the above-described error happens.

Without enabling the capability component:getsource, the progression of request messages and responses seems reasonable:

Bildschirmfoto von 2020-11-02 23-12-59

(But it complains about the missing capability component:getsource.) (list of allowed capabilities was protocol:runtime, network:status, protocol:component, graph:readonly in order to get started)

Not sure where the problem is located: My new implementation, the fbp-protocol spec or noflo-ui.

Request for comments on the above, would like to continue with the FBP protocol implementation proper.

bergie commented 3 years ago

Hey, thanks for the bug report! I think we're a little bit under-documented on how the "live mode" when connected to a runtime works.

Here's the basic flow of messaging:

So for full live mode, we need the ability to get/set source. We have to use getsource to fetch graph sources since there is no fbp-protocol method to fetch graphs in another way.

I would admit that this functionality is really poorly tested in noflo-ui when dealing with runtimes that don't provide the full set of capabilities. That's definitely an area of interest.

Let me know if I can help more.

ERnsTL commented 3 years ago

Thanks Henri for the quick reply!

It makes sense now, will continue with the implementation in this way. Hopefully I can report back with a runtime in Rust.

Another thing popped up, what is the difference between "started" and "running", for example in the network:status message?

Maybe this is because of fine differences in language/word meaning, but right now I am not sure.

The other messages look clear so far.

bergie commented 3 years ago

So: started: true, running: true means network is now running, started: true, running: false means network has finished, started: false, running: false means network was never started.

I think would be better to handle these in the fbp-protocol repo so the corner cases are more discoverable. I'll close this ticket here.