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

Sync does not work when using a function node #24

Open
Landstein opened this issue Dec 13, 2021 · 3 comments
Open

Sync does not work when using a function node #24

Landstein opened this issue Dec 13, 2021 · 3 comments

Comments

@Landstein
Copy link

When setting the state using sync it only works using the inject node. Using any other notes to pass the data gets an error

{"msg":"this._state.toJS is not a function"}

@lutzer
Copy link
Owner

lutzer commented Dec 21, 2021

could you post an example? I just tried it out and i do not have the same problem.

@michael-borkowski
Copy link

michael-borkowski commented Dec 9, 2022

Hi, I have the exact same issue. I'm not sure what the best way to show the example is, but I have the following example flow that demonstrates the issue:

[{"id":"67752b44341d2fef","type":"finite-state-machine","z":"12873024fdd5de26","name":"","fsmDefinition":"{\"state\":{\"status\":\"IDLE\",\"data\":{\"x\":5}},\"transitions\":{\"IDLE\":{\"run\":\"RUNNING\"},\"RUNNING\":{\"stop\":\"IDLE\"}}}","sendInitialState":false,"sendStateWithoutChange":false,"showTransitionErrors":true,"x":870,"y":500,"wires":[["7127f5221b2b31fd"]]},{"id":"c75957730834da98","type":"inject","z":"12873024fdd5de26","name":"","props":[{"p":"control","v":"sync","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{ \"status\": \"RUNNING\" }","payloadType":"json","x":580,"y":440,"wires":[["67752b44341d2fef"]]},{"id":"7127f5221b2b31fd","type":"debug","z":"12873024fdd5de26","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1070,"y":500,"wires":[]},{"id":"d1195305ed62b705","type":"inject","z":"12873024fdd5de26","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":430,"y":500,"wires":[["11991b912eac14a1"]]},{"id":"11991b912eac14a1","type":"function","z":"12873024fdd5de26","name":"function 4","func":"msg = {\n    control: \"sync\",\n    payload: {\n        status: \"RUNNING\"\n    }\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":580,"y":500,"wires":[["67752b44341d2fef"]]},{"id":"4fc52c5e695266ea","type":"inject","z":"12873024fdd5de26","name":"","props":[{"p":"control","v":"sync","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{ \"status\": \"IDLE\" }","payloadType":"json","x":570,"y":400,"wires":[["67752b44341d2fef"]]}]

Clicking the two first inject nodes properly syncs the FSM. Clicking the final one (which triggers the function) causes the error:

09/12/2022, 19:04:43[node: 67752b44341d2fef](http://<IP>:1880/#)
msg : Object
object
code: undefined
msg: "this._state.toJS is not a function"

It sounds like it might be happening here but it could also be anywhere else, of course.

I'm using Node-RED v3.0.2 and node-red-contrib-finite-statemachine@2.1.3 (in Docker but I don't think that plays a role). Let me know if I can provide more details :) Thanks for this work, in any case!

@heliart-steve
Copy link

I also have this exact same issue. Inject works just fine, but always throws this error from a function.
I can post a simplified example if it help.

I'm running NodeRED 3.0.2
node-red-contrib-finite-statemachine 2.1.3

Cheers.

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

No branches or pull requests

4 participants