Skip to content

DF0055: Instance Already Owns Its WebSocket Transport

Message

This instance already owns its WebSocket transport ({tier}), so it cannot take over the host's upgrade events.

Cause

attach(server) and handleUpgrade(req, socket, head) exist for the tier where the instance binds nothing itself and waits for the host to hand upgrade events over. When the options already name a local binding — ws.port or ws.sidecar (a side-car server, tier: 'sidecar') or server (a shared upgrade route, tier: 'server') — that transport is the one serving the socket, and routing a second server's upgrades into it would hand the same RPC group two conflicting bindings.

Example

ts
import { initHub } from '@devframes/hub/initiate'

const hub = initHub({ base: '/__devframes/', ws: { sidecar: true } })
hub.attach(myServer) // ✗ throws DF0055 — the side-car already serves `__ws`

// ✓ Pick one: the side-car…
const sidecar = initHub({ base: '/__devframes/', ws: { sidecar: true } })

// …or the host's own server.
const attached = initHub({ base: '/__devframes/' })
attached.attach(myServer)

Fix

Drop the attach / handleUpgrade call and let the configured transport serve the socket, or remove server / ws.port / ws.sidecar from the options so the instance leaves the binding to you. Both are advertised the same way in __connection.json, so the browser client is unaffected by the choice.

Source

Released under the MIT License.