Skip to content
Playground(another site)

bynk.ws.open_transfer_shape

Error A WebSocket on open handler does not transfer its connection into exactly one agent, so the Workers upgrade has no single Durable Object to route to (real-time track slice 3b).

A WebSocket on open must hand its connection to exactly one agent, unconditionally, as Room(room).join(user.identity, connection). On Workers the upgrade is routed to that agent's Durable Object, which holds the connection, so it needs a single target the compiler can find. Neither none nor several will do, and a transfer inside an if or a match is not found. A connection left undisposed is bynk.held.leak; a transfer whose key the edge cannot compute is bynk.ws.open_transfer_key.

Example

service gateway from websocket(in: Frame, out: Frame) {
on open (room: RoomId) -> Effect[()] by user: Member { // ✗ `connection` is never transferred
let _ <- connection.close()
()
}
}
service gateway from websocket(in: Frame, out: Frame) {
on open (room: RoomId) -> Effect[()] by user: Member {
let _ <- Room(room).join(user.identity, connection) // ✓ handed to one agent
()
}
}

In the Book

See also

  • Every code in its category, Other, on the diagnostic index.
  • bynk explain bynk.ws.open_transfer_shape shows the same from the installed toolchain, without a network.