Implications of a Task the doesn't "return"


In short, what does it mean if a Task implemented in native Javascript never calls its callback argument? I realize it’s a bit low-level, hope that kind of thing is ok to discuss here.

This is in the context of trying to make an Elm music player frontend aware of the status of its websocket connections.

Websocket.Lowlevel offers the function open, which returns a Task BadOpen WebSocket. It turns out this is implemented in such a way that this task doesn’t actually “return” in the typical case of a failed connection to a valid URL.

(If you’re curious, the code in question. The callback argument never gets called if no “open” event occurs. And here’s a possible “fix”, assuming the diagnosis is correct and this is actually a bug.)

At this stage I’m mostly curious what it actually means when a task is “left” in this state. It seems that this is probably not what open should be doing, but does it actually cause things to stick around in the Elm “runtime” in some way?

1 Like

I think this is what Evan referred to as a “Leaked” Task. There was a discussion captured that relates a bit to what you are talking about here.