Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action out node does not return to parent node randomly #8

Open
nirkons opened this issue Jul 11, 2019 · 7 comments
Open

Action out node does not return to parent node randomly #8

nirkons opened this issue Jul 11, 2019 · 7 comments
Labels

Comments

@nirkons
Copy link

nirkons commented Jul 11, 2019

Hi,

Sometimes when using multiple layers of actionflows (3-4 layers down) the action flow gets stuck "running" and never returns to the parent flow to complete the flow that called it.

For example
Flow -> Action Flow 1 -> Action Flow 2 -> Action flow 3 -> Action flow 4
Action flow 4 completes the flow, but does not return to action flow 3,
if you go to action flow 3 you still see "Running"

Also I don't know how to debug it,
there is no error, and most of the time it works, other times it just gets stuck "Running",
I verified this by putting a debug on the node before the action out node, and the flow does reach there and gets the msg.payload, so the msg.payload is in fact sent to the action out node.

is there a way to force it to finish running somehow via a timer for now or some other workaround?

thanks

@Steveorevo
Copy link
Owner

Is there a simplified flow you can paste or attach that depicts the issue? We’ll need to consistently reproduce it to resolve. Please be sure to state your platform/OS just incase it’s a lower level issue.

@nirkons
Copy link
Author

nirkons commented Jul 11, 2019

The problem is that its not consistent so sometimes the same flow works and sometimes it gets stuck, the flows themselves are complicated, I will try to create demo flows and run them again and again and see if i can reproduce the issue even at random.

I am running node red addon on Hass.IO on a powerful linux server, I think everything is dockerized, latest release
https://github.com/hassio-addons/addon-node-red/releases

node red v20.7
latest actionflow addon (2.0.3)

also there is no workaround to tell the parent flow to continue after some timeout or something like that?

@Steveorevo
Copy link
Owner

Hmm. Sounds like a timing related issue. This can be tricky. Any ratio of occurrence would help; but we do need a flow to "see/reslove" it. One item of help could be the internal global "actionflows" object. This is the internal structure that maintains a map of what-called-what and where to return too. There could be the possibility of this getting corrupted. Resetting it (but wiping out all AF) might resolve the issue and/or help trace it. I.e. you could dump it's content after one success flow and dump it again to capture a unresponsive one.

To see inside, use a function node with the code:

node.warn(global.get("actionflows"));

To "click through" the JSON tree or stringify the structure

node.warn(JSON.stringify(global.get("actionflows")));

Unfortunately Node-RED's debug window will only show so much data before truncating. You might have better luck stringifying the content and dumping it to file. Likewise, a timer might be able to check the structure and "correct/abort" for it.

@Steveorevo
Copy link
Owner

Steveorevo commented Jul 11, 2019

For more information about programming the internal object directly, see:
Action Flows and Javascript at
https://github.com/Steveorevo/node-red-contrib-actionflows#actionflows-and-javascript

@nirkons
Copy link
Author

nirkons commented Jul 11, 2019

Amazing, ok this might take me a few days but I hope to come back with more concrete debugging information,
However, I went over the link but I'm still unsure how to reset it "wipe all AF" as you said

edit: (you mean just to delete the entire global variable?)
I printed it to file, it's length is almost 300K characters, will it be OK to delete the entire variable?

edit2: @Steveorevo I've emailed you my actionflows object and the node that it got stuck on, i hope it will help a bit

Thanks!

@spali
Copy link

spali commented Jun 17, 2020

I have the same problem, but it's always reproducible in my case.
I could strip down my flow and can still reproduce it.
I also found out it makes a difference if I reuse the msg object or if I return a new one.

As I know, it is allowed to return a new object, for exactly this use-case node-red attaches after each function node the _msgid again.
For me it looks like Action Flows struggles with this.

Here the flow (hopefully self explaining)

[{"id":"43955dde.dede24","type":"tab","label":"DEBUG TEST","disabled":false,"info":""},{"id":"abfb28df.3a90c8","type":"debug","z":"43955dde.dede24","name":"not_working_action(inside): FIRES","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":880,"y":400,"wires":[]},{"id":"c4133fd0.99f1d","type":"actionflows_in","z":"43955dde.dede24","name":"not_working_action in","priority":"50","links":[],"scope":"private","x":140,"y":360,"wires":[["e9e44d33.63718"]]},{"id":"e4d70c38.4373d","type":"actionflows_out","z":"43955dde.dede24","name":"not_working_action out","links":[],"x":850,"y":360,"wires":[]},{"id":"daf4d37a.0cf03","type":"actionflows_in","z":"43955dde.dede24","name":"#deployed","priority":"50","links":[],"scope":"private","x":100,"y":180,"wires":[["7c81bfc7.90104","ac0954a.413b8a8"]]},{"id":"c5f8e617.545f28","type":"comment","z":"43955dde.dede24","name":"this debug fires, so the action runs","info":"","x":880,"y":440,"wires":[]},{"id":"d38980a0.d261a","type":"comment","z":"43955dde.dede24","name":"THIS DEBUG DOES NOT FIRE","info":"","x":570,"y":140,"wires":[]},{"id":"e9e44d33.63718","type":"function","z":"43955dde.dede24","name":"simple function returning new object as message","func":"return { payload: \"a\" };","outputs":1,"noerr":0,"x":500,"y":360,"wires":[["abfb28df.3a90c8","e4d70c38.4373d"]]},{"id":"7c81bfc7.90104","type":"actionflows","z":"43955dde.dede24","info":"Describe your action API here.","untilproptype":"num","proptype":"msg","name":"not_working_action","prop":"loop","untilprop":0,"until":"gt","loop":"none","scope":"private","perf":true,"seq":true,"x":310,"y":180,"wires":[["c4c0dbde.4433a8"]]},{"id":"c4c0dbde.4433a8","type":"debug","z":"43955dde.dede24","name":"not_working_action: NEVER FIRES","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":580,"y":180,"wires":[]},{"id":"55210513.61e2ac","type":"debug","z":"43955dde.dede24","name":"working_action(inside): FIRES","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":870,"y":560,"wires":[]},{"id":"2235f23d.2b8afe","type":"actionflows_in","z":"43955dde.dede24","name":"working_action in","priority":"50","links":[],"scope":"private","x":120,"y":520,"wires":[["df4df66d.f7ea08"]]},{"id":"53e8f84a.a480c8","type":"actionflows_out","z":"43955dde.dede24","name":"working_action out","links":[],"x":830,"y":520,"wires":[]},{"id":"79a1aed.86b6a5","type":"comment","z":"43955dde.dede24","name":"this debug fires, so the action runs","info":"","x":880,"y":600,"wires":[]},{"id":"ac0954a.413b8a8","type":"actionflows","z":"43955dde.dede24","info":"Describe your action API here.","untilproptype":"num","proptype":"msg","name":"working_action","prop":"loop","untilprop":0,"until":"gt","loop":"none","scope":"private","perf":true,"seq":true,"x":300,"y":280,"wires":[["ea6fccd4.0b475"]]},{"id":"ea6fccd4.0b475","type":"debug","z":"43955dde.dede24","name":"working_action: FIRES","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":540,"y":280,"wires":[]},{"id":"352c0a4a.7e6d86","type":"comment","z":"43955dde.dede24","name":"THIS DEBUG DOES FIRE","info":"","x":550,"y":240,"wires":[]},{"id":"df4df66d.f7ea08","type":"function","z":"43955dde.dede24","name":"simple function returning same object as message","func":"return Object.assign(msg, { payload: \"a\" });","outputs":1,"noerr":0,"x":510,"y":520,"wires":[["53e8f84a.a480c8","55210513.61e2ac"]]}]

@schwabelbauch
Copy link

Had the same issue and found out a solution:
#12 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants