There are already several similar questions, yet I can’t seem to find any that match my error. Sorry if dupe :,(!
I have the following setup for my mist websockets:
let broadcast = process.new_subject()
...
let assert Ok(_) =
fn(req: Request(Connection)) -> Response(ResponseData) {
["ws"] -> {
let self_subject = process.new_subject()
let selector =
process.new_selector()
|> process.selecting(broadcast_subject, function.identity)
|> process.selecting(self_subject, function.identity)
let subjects =
ServerSubjects(self: self_subject, broadcast: broadcast_subject)
mist.websocket(
request: req,
on_init: fn(_conn) {
#(subjects, Some(selector))
},
on_close: fn(_state) { io.println("goodbye!") },
handler: handle_ws_message,
)
}
...
And then, inside my handle_ws_message function:
fn handle_ws_message(
state: ServerSubjects(msg),
conn: mist.WebsocketConnection,
message: mist.WebsocketMessage(ServerSideMessage(msg)),
) {
mist.Text(_) -> {
task.async(fn() { process.send(subjects.broadcast, BroadcastTest) })
actor.continue(state)
}
...
}
I expect this to send a message to every alive websocket process, but somehow, i get this error instead:
=WARNING REPORT==== 13-Sep-2024::08:46:17.050599 ===
Actor discarding unexpected message: #(//erl(#Ref<0.3152999596.893386755.5847>), Nil)
=WARNING REPORT==== 13-Sep-2024::08:46:17.050703 ===
Actor discarding unexpected message: atom.create_from_string("DOWN")(//erl(#Ref<0.3152999596.893386755.5848>), Process, //erl(<0.113.0>), Normal)
Additional thing I tried: opening several tabs, each with an active websocket connection. The error still only triggers once.
Lastly: Mist (and gleam in general) has been a true joy to work with, thank you so much for making this.