-
Notifications
You must be signed in to change notification settings - Fork 7
Description
[Was told to make a GitHub issue from my Discord post]
I am noticing quite a bit of delay between a Convex Workflow status being marked as completed and then the last mutation inside of the workflow being completed. Essentially my UI is updating with the last mutation made in the workflow seconds before the Workflow status is marked as completed. In an ideal scenario it would come in at the same time.
More details:
I am triggering a Convex Workflow via a mutation on my React client. From there I will monitor the workflow's status via a custom useQuery that takes in the workflow ID. I am using the name prop to set custom names to update the user on what step they are in along the process. When it comes to the last execution inside of this workflow, it is a mutation to update the database. But the mutation triggers the useQuery of the items that have changed to show on the client before the Toast (useQuery for Workflow status) component shows it's completed. The delay is sometimes greater than a few seconds and not an ideal user experience.
Further notes:
I've also noticed that after every execution inside of a Convex Workflow that there is a state the Workflow goes in before going to the next step, I am assuming this is checking to see if there is a next execution/starting it. To fix this on the client I have even had to store the previous name of the workflow because of this transition so it does not flicker updates between going to the next operation.
Any suggestions on a solution to fix the time delay between the last operation and the workflow status being updated?
From: Ian (ianmacartney)
interesting..
how it currently works is that the workflow is a mutation. when it hits the next step(s) it hasn't done, it schedules that step to happen with the workpool. when the step(s) finish, it schedules the workflow mutation again, which runs to the next step. It's worth considering not having the follow-on mutation be enqueued, but then handling failure is not as straightforward to guarantee.. but if you file a GitHub issue for this I'll keep it in mind.
I also have another idea