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

Bug: Sending an event with unserializable data to stopped actor throws an error (in development) #5013

Open
sadn1ck opened this issue Jul 31, 2024 · 0 comments
Labels

Comments

@sadn1ck
Copy link

sadn1ck commented Jul 31, 2024

XState version

XState version 5

Description

Hey folks! Have made a repro which has all these details -

Essentially -

Sending event to a stopped actor

  • with unserializable data → throws
    • due to a JSON.stringify of the entire event object
  • serializable data → warns

public _send(event: EventFromLogic<TLogic>) {
if (this._processingStatus === ProcessingStatus.Stopped) {
// do nothing
if (isDevelopment) {
const eventString = JSON.stringify(event);
console.warn(
`Event "${event.type}" was sent to stopped actor "${this.id} (${this.sessionId})". This actor has already reached its final state, and will not transition.\nEvent: ${eventString}`
);
}
return;
}
this.mailbox.enqueue(event);
}

Expected result

I expect to not throw.

Actual result

An error was thrown for unserializable data.

Reproduction

https://stackblitz.com/edit/vitejs-vite-pl8fht?file=src%2Fmain.ts&terminal=dev

image

Additional context

Let me know if the repro is not clear! Thanks for all your work!

@sadn1ck sadn1ck added the bug label Jul 31, 2024
@sadn1ck sadn1ck changed the title Bug: Sending an event with unserializable data to stopped actor throws an error Bug: Sending an event with unserializable data to stopped actor throws an error (in development) Jul 31, 2024
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

1 participant