{"record":{"id":"f5da8ad9303c29a7","repo":"tracel-ai/burn","slug":"device-count-populated-by-the-init-handshake-durin","errorCode":null,"errorMessage":"Device count populated by the init handshake during connect","messagePattern":"Device count populated by the init handshake during connect","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-remote/src/client/runner.rs","lineNumber":285,"sourceCode":"    /// The index of this device on its server.\n    pub fn device_index(&self) -> usize {\n        self.device_index as usize\n    }\n\n    /// List every device hosted by the WebSocket server at `address`.\n    ///\n    /// Connects to index 0 to read the device count from the init handshake, then returns one\n    /// RemoteDevice per index. Remaining indices connect lazily on first use, matching the\n    /// behavior of [`Device::enumerate`](burn_backend::tensor::Device) for local backends.\n    #[cfg(feature = \"websocket\")]\n    pub fn enumerate_websocket(address: &str) -> Vec<Self> {\n        // Device 0 always exists (a server must host at least one device); connecting to it\n        // populates the device-count cell for its registry id.\n        let device = Self::websocket(address, 0);\n        device.connect();\n\n        let count = service::device_count_for(device.id)\n            .expect(\"Device count populated by the init handshake during connect\");\n\n        (0..count as usize)\n            .map(|index| Self::websocket(address, index))\n            .collect()\n    }\n\n    /// List every device hosted by an Iroh peer.\n    #[cfg(feature = \"iroh\")]\n    pub fn enumerate_iroh(endpoint: &iroh::Endpoint, peer: iroh::EndpointAddr) -> Vec<Self> {\n        let device = Self::iroh(endpoint, peer.clone(), 0);\n        device.connect();\n        let count = service::device_count_for(device.id)\n            .expect(\"Device count populated by the init handshake during connect\");\n        (0..count as usize)\n            .map(|index| Self::iroh(endpoint, peer.clone(), index))\n            .collect()\n    }\n}","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-remote/src/client/runner.rs#L267-L303","documentation":"Initialization invariant in `RemoteDevice::enumerate_websocket`: the device count cell, populated asynchronously during the WebSocket init handshake, has not been filled when read — meaning the handshake did not complete before enumeration attempted to use it, so the code panics.","triggerScenarios":"Thrown at crates/burn-remote/src/client/runner.rs:285 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the connection/init handshake completed before enumerating devices","Check network connectivity and server responsiveness at `address`","Retry the connect if the server was slow to respond"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}