[JS] startFlowServer => Whenever flows fail; it doesn’t recover
If you deploy a flow as a server via Cloud Functions, and the flow crashes, it doesn't seem to recover automatically. All future calls to the server don't seem to trigger the handler correctly.
Fail how, an exception? Do you have a way to reproduce this?
I can add some color here, since I brought this up with @huangjeff5. This is kind of a tough one to predictably reproduce, but the TLDR is that whenever there's an error in my flow server, it can't recover without restarting the server. Some examples I've run into include GenkitError: INVALID_ARGUMENT: Schema validation failed, JSON parsing errors when the response comes back in an unexpected format, which happens from time to time since it's hard to consistently and predictably return the correct format 100% of the time, and streaming errors.
I've been able to mitigate this in some capacity with try/catch blocks. For example, I have a flow that generates an image and returns the image URL, and I can just return a string and handle that client side in the event of an error. However, there are often times when I just want to send an error to the client without the server crashing.
There are some patterns to handle this in a regular express server, but it's not clear how to do this sort of thing in the flow server. In addition, if you simply throw an error like this
app.get('/', (req, res) => {
throw new Error('BROKEN') // Express will catch this on its own.
})
express doesn't catch the error on its own in the flow server, and it crashes.
Hi @devchas , does this happen to you using Cloud Functions?