Has anyone encountered Workflows failing

Has anyone encountered Workflows failing with the following error: (instance.in_finite_state) Instance reached a finite state, cannot send events to it
15 Replies
avenceslau
avenceslau•2mo ago
Hey 👋 , this means that your instance has completed or errored (or was terminated) before you sent your event to it.
Nathan Scheele
Nathan ScheeleOP•2mo ago
Interesting. The Workflow in question doesn't receive events, but instead is supposed to send them. I'd think there would be an error if it failed, no?
avenceslau
avenceslau•2mo ago
The caller of sendEvent should receive an error if the instance that should receive the event is in a terminal state. Isn't that the case with yours? (not sure if I understood)
Nathan Scheele
Nathan ScheeleOP•2mo ago
I have parent-child workflows setup, where the parent will spawn other workflows and wait for them to finish with waitForEvent. As far as I can tell, the parent is still waiting when the child fails with that error. See attached for the most recent time I encountered it.
No description
No description
avenceslau
avenceslau•2mo ago
Can you send me the instance ids? You can just link me to both dash pages I can get instance ids from there
jordanfinners
jordanfinners•2mo ago
Yeah I've had this but it tends to be when one of the workflow internal errors happens
Nathan Scheele
Nathan ScheeleOP•2mo ago
@avenceslau Wanted to followup to see if you had any thoughts
avenceslau
avenceslau•2mo ago
Not yet will investigate as soon as I can sorry about that
Nathan Scheele
Nathan ScheeleOP•2mo ago
No worries! Thanks a lot
avenceslau
avenceslau•2mo ago
Hi would you mind sharing the relevant code, you can send it to me via DM if you prefer
Nathan Scheele
Nathan ScheeleOP•2mo ago
Apologies for the delay. Here's the relevant code. The idea behind it is to get around the 1k subrequest limit per worker invocation. So for any subrequest-intensive work, I dispatch the relevent information to a separate Workflow to make all of the subrequests.
avenceslau
avenceslau•2mo ago
Hi, I have a couple of questions: - Is your SubrequestManager.ts supposed to run as a workflow? or will it run inside a step? - Are you still getting the same errors as of right now? We made a few changes that will minimize internal workflows errors and help with send/receive event
Nathan Scheele
Nathan ScheeleOP•2mo ago
Hey! 1. Yes, you would create a new SubRequestManager in the primary Workflow, which would then create and wait for an instance of a separate (secondary) Workflow to run to completion. The odd thing is that I was getting the above errors in the secondary Workflow, even though the primary Workflow was still waiting on an event. 2. I have not, but also haven't tried! I will test and report back
avenceslau
avenceslau•2mo ago
If you run SubRequestManager as a workflow I would do this await subRequestWorkflow.create({ params: payload }); inside of a step.do, a workflow might "restart" for many reasons, and operations with side effects should run inside a step.do so that we can ensure that it only runs once.

Did you find this page helpful?