tracel-ai/burn · error

Device count populated by the init handshake during connect

Error message

Device count populated by the init handshake during connect

What it means

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.

Source

Thrown at crates/burn-remote/src/client/runner.rs:285

    /// The index of this device on its server.
    pub fn device_index(&self) -> usize {
        self.device_index as usize
    }

    /// List every device hosted by the WebSocket server at `address`.
    ///
    /// Connects to index 0 to read the device count from the init handshake, then returns one
    /// RemoteDevice per index. Remaining indices connect lazily on first use, matching the
    /// behavior of [`Device::enumerate`](burn_backend::tensor::Device) for local backends.
    #[cfg(feature = "websocket")]
    pub fn enumerate_websocket(address: &str) -> Vec<Self> {
        // Device 0 always exists (a server must host at least one device); connecting to it
        // populates the device-count cell for its registry id.
        let device = Self::websocket(address, 0);
        device.connect();

        let count = service::device_count_for(device.id)
            .expect("Device count populated by the init handshake during connect");

        (0..count as usize)
            .map(|index| Self::websocket(address, index))
            .collect()
    }

    /// List every device hosted by an Iroh peer.
    #[cfg(feature = "iroh")]
    pub fn enumerate_iroh(endpoint: &iroh::Endpoint, peer: iroh::EndpointAddr) -> Vec<Self> {
        let device = Self::iroh(endpoint, peer.clone(), 0);
        device.connect();
        let count = service::device_count_for(device.id)
            .expect("Device count populated by the init handshake during connect");
        (0..count as usize)
            .map(|index| Self::iroh(endpoint, peer.clone(), index))
            .collect()
    }
}

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Ensure the connection/init handshake completed before enumerating devices
  2. Check network connectivity and server responsiveness at `address`
  3. Retry the connect if the server was slow to respond
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at crates/burn-remote/src/client/runner.rs:285 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05). Data as JSON: /api/errors/f5da8ad9303c29a7. Report an issue: GitHub.