Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

Unable to send event from child to parent #380

Open
sinchinpark opened this issue Aug 14, 2022 · 2 comments
Open

Unable to send event from child to parent #380

sinchinpark opened this issue Aug 14, 2022 · 2 comments

Comments

@sinchinpark
Copy link

sinchinpark commented Aug 14, 2022

Description

calling sendParent() or send({}, {to: parent}) from invoked child machine thrown Uncaught Error

Expected Result

Event fetched in parent machine

Actual Result

No event was received in the parent machine

Uncaught Error: Unable to send event to child '#_parent' from service {child}.
at e.sendTo (interpreter.js:119:17)
at interpreter.js:739:15
at r (helpers.js:72:23)

Reproduction

consider this viz

Additional context

Browser: Vivaldi 5.3.2679.70 (Stable channel) (chromium-based browser)
OS: Linux (Ubuntu 22.04 LTS)

@Andarist
Copy link
Member

This is a byproduct of our strategy to evaluate the top-level machines from the code editor. The visualizer in here might actually try to create fetchService twice - once as a standalone machine, once as the child of the app. The first one throws but the latter works OK:
https://codesandbox.io/s/pedantic-montalcini-v3w2rx?file=/src/index.js

To workaround this issue I recommend wrapping this fetchMachine in a factory function, like here:
https://stately.ai/viz/3e0a792e-f3e4-4820-a45e-2fb6374c9978

This is still an issue with the visualizer though and we should revisit fixing this in the future.

@sinchinpark
Copy link
Author

@Andarist Thnx for your fast reply. BTW the initial link in my first post was incorrect so I fixed it.

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

No branches or pull requests

2 participants