bynk.ws.open_transfer_cross_file
Error On the Workers target, a WebSocket on open handler transfers its connection to an agent declared in a different file of the same context — the open is hosted in the agent's Durable Object, which is emitted from the agent's own file, so the upgrade would never be handled; the service and the agent must share a file.
On the Workers target, a from websocket service's on open is hosted inside the Durable Object of the agent it hands the connection to, and that method is emitted from the file the service and the agent share. When a context is split over several files, each is emitted on its own, so a service in one file that transfers to an agent in another would be routed to the agent's Durable Object and never handled there: the upgrade would answer 404. The compiler refuses the layout. Put the service in the agent's file, or build for --target bundle, where the open is an ordinary method and the layout works.
Example
service ChatGateway from websocket(in: ClientFrame, out: ServerFrame) { on open (roomId: RoomId) -> Effect[()] by v: Visitor { // ✗ `Room` is declared in another file let _ <- Room(roomId).join(connection) () }}
// chat/room.bynkagent Room { key id: RoomId}
// chat/room.bynkservice ChatGateway from websocket(in: ClientFrame, out: ServerFrame) { // ✓ in the agent's file on open (roomId: RoomId) -> Effect[()] by v: Visitor { let _ <- Room(roomId).join(connection) () }}In the Book
See also
- Every code in its category, Other, on the diagnostic index.
bynk explain bynk.ws.open_transfer_cross_fileshows the same from the installed toolchain, without a network.