Race condition issue in credit check example #4895
-
I'm not sure if this is a bug or misuse on my part, so apologies if this is better suited as an issue instead of a Q/A; this felt like a safer place to start. In the credit check example, I run into a problem where the calls to the observer's I have a repository with a minimal recreation of the issue: https://github.com/gepenrose/xstate-exmple-issue
I have a hacky temporary solution to get around this in my project, but I was wondering if there was any recommended way to fix this, if this is something that can be fixed in the example, or if this is something that can be fixed in XState. The only solution that comes to mind on the XState side is a mechanism to subscribe to emitted snapshots synchronously where the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Thanks for the report! From initial glance, it seems like the best way to fix this is to use a task queue. Whenever you get a new snapshot, add it to the task queue and process saving the snapshots one at a time. |
Beta Was this translation helpful? Give feedback.
-
@davidkpiano fan of your great work on xstate and introducing actor model to programming to many developers by xstate. @azasorin-rss @davidkpiano , want to understand question 1 ( using queue to save state in db at end of event transition will give consistency of overall state ? ) if using queue at end ( on subscribe next ) to save db state is working, @davidkpiano is there any plan to push, #5071 [core] Synchronizers #5071 into xstate V6. |
Beta Was this translation helpful? Give feedback.
Thanks for the report! From initial glance, it seems like the best way to fix this is to use a task queue.
Whenever you get a new snapshot, add it to the task queue and process saving the snapshots one at a time.