xtekky/gpt4free · error · Exception
Upload timeout for {file_id}
Error message
Upload timeout for {file_id} What it means
Raised by OperaAria's media upload when the polling loop (60 attempts, sleeping 1s up to 2s between polls) never observes upload_status == 'finished' and never sees a terminal 'failed'/'error' status. It is a client-side timeout: total wait approaches ~90-100 seconds before giving up.
Source
Thrown at g4f/Provider/OperaAria.py:256
data=media_bytes,
) as response:
response.raise_for_status()
# Step 3: Poll for completion
for attempt in range(60):
async with session.get(
f"{cls.files_endpoint}{file_id}", headers=headers
) as response:
response.raise_for_status()
result = await response.json()
status = result.get("upload_status")
if status == "finished":
return file_id
if status in ("failed", "error"):
raise Exception(f"Upload failed: {result}")
await asyncio.sleep(min(1 + attempt * 0.3, 2))
raise Exception(f"Upload timeout for {file_id}")
@classmethod
async def _process_media(
cls,
session: ClientSession,
access_token: str,
media: MediaListType,
messages: Messages,
) -> list:
"""Process and upload all media (V2 only)."""
attachments = []
for media_data, media_name in merge_media(media, messages):
try:
if isinstance(media_data, str) and media_data.startswith("data:"):
media_bytes = base64.b64decode(media_data.split(",", 1)[1])
elif isinstance(media_data, str) and media_data.startswith(
("http://", "https://")
):View on GitHub (pinned to 973504e177)
Solutions
- Retry the request — slow processing often completes on a second attempt.
- Reduce file size/resolution before upload to shorten processing time.
- If you control the code, raise the poll budget in OperaAria._upload_file (range(60) / sleep cap).
- Update g4f in case upstream polling was retuned.
Example fix
# before (provider-internal: 60 polls)
for attempt in range(60):
...
# after - local guard: retry once on timeout
try:
result = await OperaAria.create_async_generator(model, messages, media=media)
except Exception as e:
if 'Upload timeout' in str(e):
result = await OperaAria.create_async_generator(model, messages, media=smaller_media)
else:
raise Defensive patterns
Strategy: retry
Validate before calling
def sized_for_opera_upload(size_bytes: int) -> bool:
return 0 < size_bytes <= 8 * 1024 * 1024 # keep processing under poll budget Try / catch
try:
result = await OperaAria.create_async_generator(model, messages, media=media)
except Exception as e:
if 'Upload timeout' in str(e):
await asyncio.sleep(5)
result = await OperaAria.create_async_generator(model, messages, media=media) # one retry Prevention
- Shrink large files before upload
- Retry once — server processing often finishes on second attempt
- Avoid many concurrent uploads
- Keep g4f updated for retuned poll budgets
When it happens
Trigger: Uploading a large file whose server-side processing exceeds the fixed 60-poll budget; slow or stalled Opera backend; network/proxy latency stretching poll intervals so the status flips to 'finished' just after the last poll.
Common situations: Large images or videos on slow connections; transient Opera service degradation; running many concurrent uploads that starve the event loop and delay polls.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Upload failed: {result}
- Timeout error after {timeout} sec
- Failed to upload file: {res_json}
- {data['code']}:{data['details']}
- Aliyun captcha SDK failed to load
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/07b451df39b7e247.
Report an issue: GitHub.