Zaid-Ajaj/Fable.Remoting

Client hangs when using FSharpPlus.Data.NonEmptySeq

Opened this issue · 1 comments

When using NonEmptySeq or NonEmptyList from FSharpPlus.Data in the response type, the client gets stuck in the loading state.

Example

type IApi = {
    test: unit -> Async<NonEmptySeq<string>>
}
let update msg model =
    match msg with
    | LoadBookings msg ->
        match msg with
        | Start() ->
            let cmd = Cmd.OfAsync.perform api.test () (Finished >> LoadBookings)

            { model with Bookings = Loading }, cmd
        | Finished bookingsPage ->
            printfn "bookingsPage: %A" bookingsPage // THIS NEVER GETS TRIGGERED
            { model with Bookings = Loaded(bookingsPage) }, Cmd.none

The frontend does the start command to trigger the request. The request succeeds and responds with:

["Hello","World"]

However, the frontend Finished command never gets triggered, and no error seem to be logged.

If I change the type to a native seq it works again.

Is this a bug? (newbie here, could be missing something)

Hi there @madyanalj when you use Cmd.OfAsync.perform, the error is ignored. You probably want Cmd.OfAsync.either where the last argument is (Exception -> 'Msg) so you can add a new Msg type called LoadingBooksFailed of exn which you then handle in your update to either show the error or print it in the console.

Is this a bug? (newbie here, could be missing something)

Could be a bug with Fable.SimpleJson, the library used fro client-side deserialization but I highly doubt it. I am assuming that you are using a version of FSharpPlus that supports Fable, is that correct?