Zaid-Ajaj / Fable.Remoting

Type-safe communication layer (RPC-style) for F# featuring Fable and .NET Apps
https://zaid-ajaj.github.io/Fable.Remoting/
MIT License
272 stars 54 forks source link

Regression in Fable.Remoting.Client 7.9 causing XMLHttpRequest errors to be ignored #249

Closed bklop closed 3 years ago

bklop commented 3 years ago

Commit 4cd23641182ca82e27dfafa25dc827295840b28b added support for cancellation, but also checks for xhr.status <> 0 which causes it to swallow any XMLHttpRequest errors.

In practice this means that client code such as this (using Elmish here as an example)

Cmd.OfAsync.either
    MyProxy.someApi.doSomething
    ()
    SomethingSuccess
    SomethingError

will never dispatch a SomethingError msg in case of a network error (for example, a lost connection). This is breaking application functionality for us and we were forced to rollback to Fable.Remoting.Client 7.8 for now :).

Zaid-Ajaj commented 3 years ago

Hi there @bklop thanks for filing the issue, this is interesting because I thought this test would make sure we are throwing proper errors 🤔 so is this only when status code = 0? (i.e. cors/connectivity error)

bklop commented 3 years ago

Yeah exactly. I'm not sure why xhr.status <> 0 was added in that commit, shouldn't it be sufficient to check for ReadyState.Done && not token.IsCancellationRequested?

Zaid-Ajaj commented 3 years ago

Done! The fix should be available in v7.11 🚀