High severity intermediate · Fix: 5-10 min

TimeoutError

asyncio.exceptions.TimeoutError

What this error means
LangSmith run upload fails due to an asynchronous timeout when the upload process exceeds the allowed time limit.

Stack trace

traceback
Traceback (most recent call last):
  File "app.py", line 42, in upload_run
    await client.runs.upload(run)
  File "langsmith/client.py", line 210, in upload
    await asyncio.wait_for(self._upload_run_data(run), timeout=30)
  File "/usr/lib/python3.9/asyncio/tasks.py", line 481, in wait_for
    raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError
QUICK FIX
Increase the timeout parameter in the LangSmith run upload call to a higher value to prevent premature timeout errors.

Why it happens

The LangSmith client uses asyncio.wait_for to limit the time allowed for uploading run data. If the upload process takes longer than the specified timeout (default 30 seconds), asyncio raises a TimeoutError. This can happen due to network latency, large payloads, or server-side delays.

Detection

Monitor your async upload calls for TimeoutError exceptions and log the duration of each upload to detect slow or stalled uploads before they fail.

Causes & fixes

1

Large run data payload causing slow upload exceeding the timeout limit

✓ Fix

Reduce the size of the run data payload or increase the timeout parameter in the upload call to allow more time.

2

Network latency or connectivity issues delaying the upload process

✓ Fix

Ensure stable network connectivity and consider retrying uploads with exponential backoff on timeout errors.

3

LangSmith server-side processing delays causing slow response

✓ Fix

Contact LangSmith support to check server status or increase client-side timeout to accommodate slower responses.

Code: broken vs fixed

Broken - triggers the error
python
import asyncio
from langsmith import LangSmithClient

client = LangSmithClient(api_key=os.environ["LANGSMITH_API_KEY"])

async def upload_run(run):
    # This line triggers TimeoutError if upload takes longer than 30 seconds
    await client.runs.upload(run)

# asyncio.run(upload_run(my_run))
Fixed - works correctly
python
import os
import asyncio
from langsmith import LangSmithClient

client = LangSmithClient(api_key=os.environ["LANGSMITH_API_KEY"])

async def upload_run(run):
    # Increased timeout to 60 seconds to avoid TimeoutError
    await asyncio.wait_for(client.runs.upload(run), timeout=60)

# asyncio.run(upload_run(my_run))
print("Run upload completed successfully.")
Wrapped the upload call with asyncio.wait_for and increased the timeout to 60 seconds to allow more time for large or slow uploads.

Workaround

Catch asyncio.exceptions.TimeoutError around the upload call, then retry the upload after a short delay or fallback to uploading smaller chunks of run data.

Prevention

Implement upload retries with exponential backoff and monitor upload durations; also optimize run data size and use stable network connections to avoid hitting timeouts.

Python 3.9+ · langsmith >=0.1.0 · tested on 0.4.2
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.