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

TypeError: Cannot read properties of undefined (reading 'name') #2880

Closed
huan opened this issue Dec 18, 2021 · 3 comments · Fixed by #3126
Closed

TypeError: Cannot read properties of undefined (reading 'name') #2880

huan opened this issue Dec 18, 2021 · 3 comments · Fixed by #3126
Assignees
Labels

Comments

@huan
Copy link
Contributor

huan commented Dec 18, 2021

Description

When a child machine has been in a state with the exit: sendParent action set, if the parent machine stop, then the error will be thrown.

I guess this is because the parent has been destroyed before the child.

Expected Result

The interpreter should be stopped gracefully. (executed all the exit from all children before destroy parent?)

Actual Result

TypeError: Cannot read properties of undefined (reading 'name')

Reproduction

https://codesandbox.io/s/loving-sutherland-y3he8?file=/src/index.ts

Additional context

@Andarist
Copy link
Member

I can confirm that this is a bug - and most likely a duplicate of another issue. I will try to look into this after the weekend as I already exactly know what happens, just need to figure out the most appropriate solution and write tests for this and related scenarios.

@Andarist Andarist self-assigned this Dec 18, 2021
@Andarist
Copy link
Member

Andarist commented Jan 1, 2022

Just an update - I'm implementing a fix for this, should open a PR in a couple of days. The issue/fix is somewhat delicate so I'm making sure to cover as many edge cases as I can.

@ptaranto
Copy link

ptaranto commented Feb 15, 2022

Hey @Andarist any update on this?

I'm having the issue when sending an event from child to grandchild machine, here is a CDS for it: https://codesandbox.io/s/xstate-stop-parent-child-grandchild-tuv3nk?file=/src/App.tsx

when stoping the parent machine by clicking the button there's another error related to not being able to read listeners
to reproduce the original error related to this issue, it'll occur whenever you change the code in App and CDS hot reload happens

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