{"record":{"id":"52de202fef0c824e","repo":"tracel-ai/burn","slug":"failed-to-send-download-id","errorCode":null,"errorMessage":"Failed to send download id","messagePattern":"Failed to send download id","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-communication/src/external_comm.rs","lineNumber":158,"sourceCode":"    pub async fn download_tensor(\n        &self,\n        remote: Address,\n        transfer_id: TensorTransferId,\n    ) -> Option<TensorData> {\n        log::info!(\"Downloading tensor from {remote:?}\");\n\n        let stream = self.get_data_stream(remote).await;\n        let mut stream = stream.lock().await;\n\n        // Send the download request with the download id\n        let bytes: bytes::Bytes =\n            rmp_serde::to_vec(&ExternalCommMessage::TensorRequest(transfer_id))\n                .unwrap()\n                .into();\n        stream\n            .send(Message::new(bytes))\n            .await\n            .expect(\"Failed to send download id\");\n\n        if let Ok(msg) = stream.recv().await {\n            let Some(msg) = msg else {\n                log::warn!(\"Received None message from the websocket, closing connection.\");\n                return None;\n            };\n\n            let ExternalCommMessage::Tensor(data) = rmp_serde::from_slice(&msg.data)\n                .expect(\"Can deserialize messages from the websocket.\")\n            else {\n                panic!(\"Message should have been TensorData\")\n            };\n            return Some(data);\n        }\n        log::warn!(\"Closed connection\");\n        None\n    }\n","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-communication/src/external_comm.rs#L140-L176","documentation":"This panic occurs in download_tensor after connecting to a peer server and sending a TensorRequest message containing the transfer id. The expect fires if the websocket send fails, meaning the download cannot even be initiated. Since the module also tolerates peer closure later (recv returns None), this failure indicates the connection broke between open and send.","triggerScenarios":"Calling download_tensor against a peer whose socket dropped right after connect — peer crashed, network reset, or the stream was concurrently closed by another task (e.g. close() draining streams while a download is in flight).","commonSituations":"Distributed/data-parallel runs where a peer dies mid-tensor-transfer; requesting tensors from a server that is shutting down; unstable network links between containers/nodes.","solutions":["Retry the download after re-establishing the peer connection; the failure is often transient.","Verify the peer server is running and accepting tensor requests before downloading.","Check for concurrent close() calls racing with in-flight downloads and serialize shutdown.","Surface send errors as a proper None/error return instead of panicking, matching the existing recv-None handling."],"exampleFix":"// before\nstream.send(Message::new(bytes)).await.expect(\"Failed to send download id\");\n// after\nstream.send(Message::new(bytes)).await.map_err(|e| {\n    log::warn!(\"failed to send tensor request {transfer_id}: {e}\");\n    e\n})?;","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"stream.send(Message::new(bytes)).await\n    .map_err(|e| { log::warn!(\"send failed for {transfer_id}: {e}\"); e })?;\n// caller: retry download once on transient send error","preventionTips":["Check peer liveness before initiating tensor downloads.","Avoid racing close() with in-flight downloads — serialize shutdown.","Add automatic reconnect-and-retry for transient websocket send failures."],"tags":["websocket","network","tensor-transfer","panic"],"backgroundTag":"websocket-send-failed","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}