Moya: Eidolon goes into deadlock when requesting from network whilst offline?

I noticed an interesting bug with my networking code. All of my requests go through this observable, that I think pulled code 1:1 from https://github.com/artsy/eidolon:

return online
            .ignore(false)  // Wait until we're online
            .take(1)        // Take 1 to make sure we only invoke the API once.
            .flatMap { _ in // Turn the online state into a network request
                return actualRequest
            }

The issue I’m running in to is when the app is completely offline, my request never returns. i.e. I request logIn, and my UI is blocked for eternity, or until I relaunch the app. Should I be running my requests with a timeout to prevent this sort of deadlock?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

@ashfurrow yup, that sounds like the way it should be done.

I’ve been thinking: it would be really useful to extract Eidolen’s networking stack into a sub-repo. Two reasons:

  1. Many @Moya/contributors often link to Eidolon as an implementation example, having a repo with just the networking part of eidolon would be easier for new readers to digest
  2. Eidolon has a pretty great RxMoya networking stack, I used almost an exact copy of it in the app that I was previously working on. It would be awesome if the two of us (and whoever else) could share an opinionated RxMoya implementation, so we can fix things like deadlocks together.

I’m free today, I could create the repo (not sure if it makes sense to have it under artsy or Moya), and then also create a PR to eidolon that removes the code from App/Networking/ and includes it through the new repo

Cheers