Describe the problem/error/question
Hi everyone,
I’m facing a challenge with a workflow and could use some expert advice. I’ve tried a few common patterns but seem to be hitting a wall.
I have an n8n workflow with the following structure (simplified verison):
-
It gets triggered by a webhook.
-
It processes the data using the Gemini chat model.
-
It sends a response back using the “Respond to Webhook” node.
Also I use self-hosted instance of n8n.
The problem is the Gemini node occasionally gets stuck. It doesn’t return an error, it just hangs. Eventually, the entire n8n execution times out.
When this happens, n8n sends its default timeout message. My goal is to intercept this “hanging” state and, after a shorter custom duration (e.g., 90 seconds), send my own standard error response and cancel the stuck Gemini node.
I have already posted a Topic in ‘help me build my workflow’, but as I am in a hurry and I have few questions, I am posting this again.
My other Topic:
https://community.n8n.io/t/how-to-send-a-custom-response-on-timeout-for-a-specific-workflow/235429
Here’s what I’ve tried:
1. Error Workflow
This didn’t work. It seems the main execution timeout is not an “error” that triggers the configured Error Workflow. The workflow simply halts and sends the default n8n response.
2. Custom timeout with wait node
I tried creating two parallel branches, one with my AI Agent node and one with a wait node. I wanted the wait node to act as a timeout. my plan was that these two branches run as same time and the one who finishes first, sends the respond.
This failed because it starts executing Branch A and after finishing that, it started Branch B.
3. Sub-Workflow Parallelism
After some research, I put the AI Agent node and the Wait node into two separate sub-workflows and called them concurrently from the main workflow.
This did run them in parallel, but both sub-workflows complete in the background, so the logic of ‘complete only the earliest one’ fails here and I found no way to cancel the AI Agent sub-workflow if the Wait sub-workflow “wins” the race. The Gemini process would just keep running uselessly in the background.
My question is:
-
Is there a per-node timeout setting (especially for ai agent/chat model node) that I’m missing? This seems like the simplest solution.
-
What is the correct n8n pattern to create a scenario where the winning branch can actively cancel the losing, still-running branch?
-
As a last resort, is there any way to override n8n’s default execution timeout response on a per-workflow basis?
The default n8n response (500 status code):
{
"code": 0,
"message": "The execution was cancelled because it timed out"
}
Our project’s standard response format (200 status code):
{
"code": 408,
"msg": "TIMEOUT_ERROR",
"data": null
}
My Workflow:
Information on your n8n setup
- n8n version: 1.121.3 self-host
- Database (default: SQLite): Postgres
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
- Operating system: