{"record":{"id":"18bb31b2f24127a8","repo":"home-assistant/core","slug":"upload-timed-out-after-upload-timeout-seconds","errorCode":null,"errorMessage":"Upload timed out after {UPLOAD_TIMEOUT} seconds","messagePattern":"Upload timed out after (.+?) seconds","errorType":"exception","errorClass":"BackupAgentError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/backblaze_b2/backup.py","lineNumber":371,"sourceCode":"        _LOGGER.debug(\"Uploading backup file %s with streaming\", filename)\n        try:\n            content_type, _ = mimetypes.guess_type(filename)\n            file_version = await asyncio.wait_for(\n                self._hass.async_add_executor_job(\n                    self._upload_unbound_stream_sync,\n                    reader,\n                    filename,\n                    content_type or \"application/x-tar\",\n                    file_info,\n                ),\n                timeout=UPLOAD_TIMEOUT,\n            )\n        except TimeoutError:\n            _LOGGER.error(\n                \"Upload of %s timed out after %s seconds\", filename, UPLOAD_TIMEOUT\n            )\n            reader.abort()\n            raise BackupAgentError(\n                f\"Upload timed out after {UPLOAD_TIMEOUT} seconds\"\n            ) from None\n        except asyncio.CancelledError:\n            _LOGGER.warning(\"Upload of %s was cancelled\", filename)\n            reader.abort()\n            raise\n        finally:\n            reader.close()\n\n        _LOGGER.debug(\"Successfully uploaded %s (ID: %s)\", filename, file_version.id_)\n\n    @handle_b2_errors\n    @override\n    async def async_delete_backup(self, backup_id: str, **kwargs: Any) -> None:\n        \"\"\"Delete a backup and its associated metadata file from Backblaze B2.\"\"\"\n        file, metadata_file = await self._find_file_and_metadata_version_by_id(\n            backup_id\n        )","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/backblaze_b2/backup.py#L353-L389","documentation":"BackupAgentError raised in the B2 upload path when the bucket.upload_file(...) future exceeds UPLOAD_TIMEOUT seconds. The read stream is aborted (reader.abort()), an error is logged with the filename and the timeout value, and the timeout re-raises as BackupAgentError via 'raise ... from None' (TimeoutError is not chained).","triggerScenarios":"asyncio.wait_for-style timeout around the executor upload future fires: the upload of the backup tar to B2 did not complete within UPLOAD_TIMEOUT, typically because of insufficient bandwidth for the backup size or a stalled connection.","commonSituations":"Large backups on slow uplinks (e.g. tens of GB on ADSL), throttled connections, VPN/proxy stalling large streams, B2 transient slowness.","solutions":["Retry the backup during low network usage; the abort cleans the partial upload","Reduce backup size (exclude media or use a partial backup)","Check upstream bandwidth stability (a stalled, not merely slow, connection also trips the fixed timeout)","If recurring, file an issue proposing a configurable/bandwidth-aware timeout; the constant is fixed in code"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# pre-flight: estimate upload time vs fixed timeout\nestimated_seconds = backup.size * 8 / (uplink_bits_per_sec * 0.8)\nif estimated_seconds > UPLOAD_TIMEOUT:\n    # exclude data or split the backup before starting","typeGuard":"def is_upload_timeout(err: BaseException) -> bool:\n    from homeassistant.components.backup.exceptions import BackupAgentError\n    return isinstance(err, BackupAgentError) and \"timed out\" in str(err)","tryCatchPattern":"try:\n    await asyncio.wait_for(upload_future, timeout=UPLOAD_TIMEOUT)\nexcept TimeoutError:\n    reader.abort()\n    raise BackupAgentError(f\"Upload timed out after {UPLOAD_TIMEOUT} seconds\") from None","preventionTips":["Measure uplink bandwidth and size backups to finish within the fixed timeout","Use partial backups to cut size on slow connections","Retry at off-peak hours; the reader.abort() cleanup prevents partial-file residue"],"tags":["backblaze","b2","backup","timeout","upload"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}