Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client hangs when using FSharpPlus.Data.NonEmptySeq #371

Open
madyanalj opened this issue Oct 14, 2024 · 1 comment
Open

Client hangs when using FSharpPlus.Data.NonEmptySeq #371

madyanalj opened this issue Oct 14, 2024 · 1 comment

Comments

@madyanalj
Copy link

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)

@Zaid-Ajaj
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@Zaid-Ajaj @madyanalj and others