ScrapeGraphAI/Scrapegraph-ai · error · Timeout
Response took longer than {timeout} seconds
Error message
Response took longer than {timeout} seconds What it means
GenerateAnswerNode.invoke_with_timeout calls chain.invoke() and afterwards compares elapsed wall time against the timeout; if the call took longer than the limit, langchain_core.errors.Timeout is raised (and logged) so the graph can branch on RetryError/timeout handling.
Source
Thrown at scrapegraphai/nodes/generate_answer_node.py:83
if node_config.get("schema", None) is None:
self.llm_model.format = "json"
else:
self.llm_model.format = self.node_config["schema"].model_json_schema()
self.verbose = node_config.get("verbose", False)
self.force = node_config.get("force", False)
self.script_creator = node_config.get("script_creator", False)
self.is_md_scraper = node_config.get("is_md_scraper", False)
self.additional_info = node_config.get("additional_info")
self.timeout = node_config.get("timeout", 480)
def invoke_with_timeout(self, chain, inputs, timeout):
"""Helper method to invoke chain with timeout"""
try:
start_time = time.time()
response = chain.invoke(inputs)
if time.time() - start_time > timeout:
raise Timeout(f"Response took longer than {timeout} seconds")
return response
except Timeout as e:
self.logger.error(f"Timeout error: {str(e)}")
raise
except Exception as e:
self.logger.error(f"Error during chain execution: {str(e)}")
raise
def process(self, state: dict) -> dict:
"""Process the input state and generate an answer."""
user_prompt = state.get("user_prompt")
# Check for content in different possible state keys
content = (
state.get("relevant_chunks")
or state.get("parsed_doc")
or state.get("doc")
or state.get("content")
)View on GitHub (pinned to 532dfffbf6)
Solutions
- Increase the timeout in graph config: {'llm': {...}, 'timeout': 300} or the node/model timeout setting
- Reduce input size (truncate docs) or lower max_output_tokens so responses finish faster
- Implement the node's retry/error-handling path or catch Timeout upstream and retry with backoff
Example fix
# before
graph_config = {'llm': {'model': 'openai/gpt-4o'}, 'timeout': 60}
# after
graph_config = {'llm': {'model': 'openai/gpt-4o'}, 'timeout': 300} Defensive patterns
Strategy: retry
Validate before calling
# pre-flight: choose timeout proportional to expected output size est_tokens = len(docs_text) // 4 timeout = max(120, est_tokens // 100) # rough heuristic
Try / catch
from langchain_core.errors import Timeout
for attempt in range(2):
try:
result = node.invoke_with_timeout(chain, inputs, timeout)
break
except Timeout:
if attempt == 1:
raise
timeout *= 2 Prevention
- Set timeout generously for long generations (300s+)
- Truncate large document contexts before the answer node
- Implement exponential-backoff retries around LLM invocations
When it happens
Trigger: A slow LLM (long generation, rate-limit retries inside the client, overloaded provider) making chain.invoke exceed the configured timeout (e.g. 90s default) set via config 'timeout'.
Common situations: Large contexts/long outputs with small timeouts; provider throttling; intermittent network latency; timeout too aggressive for reasoning models.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Could not determine model name from llm_model. Please specif
- PDF parsing exceeded timeout of {self.timeout} seconds
- Model not supported
- model_tokens not specified
- Provider {llm_params["model_provider"]} is not supported.
AI-assisted analysis of ScrapeGraphAI/Scrapegraph-ai@532dfffbf6 (2026-08-28).
Data as JSON: /api/errors/37231215ca251f0d.
Report an issue: GitHub.