You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Invoked actors are not cleared from the system upon re-entry.
constmachine=createMachine({initial: 'Listening',states: {Listening: {invoke: {systemId: 'listener',// <-- This will clash with the subsequently invoked listenersrc: fromCallback(()=>{console.log('✅ invoked the listener')return()=>{console.log('⛔ clearing the listener')}}),},},},on: {RESTART: {// reenters Listening, tries to invoke the listener, but:// 🪲 Actor with system ID 'listener' already exists.target: '.Listening',},},})
Expected result
After receiving the RESTART event, the first listener is cleared first (its unsubscribe function should run), its systemId should be removed from actor.system, and then a fresh listener should be invoked.
Actual result
Error upon receiving the RESTART event:
Error: Actor with system ID 'listener' already exists.
Description
Invoked actors are not cleared from the system upon re-entry.
Expected result
After receiving the RESTART event, the first listener is cleared first (its unsubscribe function should run), its systemId should be removed from actor.system, and then a fresh listener should be invoked.
Actual result
Error upon receiving the RESTART event:
Reproduction
https://codesandbox.io/s/optimistic-bush-7lh38j?file=/src/index.js
Additional context
This is an issue with xstate v5.
Occurs with: [email protected]
The text was updated successfully, but these errors were encountered: