DeclarativeHub / ReactiveKit

A Swift Reactive Programming Kit
MIT License
1.24k stars 114 forks source link

Deadlocks. #279

Open escfrya opened 2 years ago

escfrya commented 2 years ago

Hi guys! First of all, thanks for great work! We use ReactiveKit a lot and after our project was grown we ran into problem with deadlocks.

Most of our Services(business logic) works in this way:

event
    .with(latestFrom: state)
    .map { event, state in
        var newState = state
        // Apply event to state
        return newState
    }
    .bind(to: state)

With time logic gets complicated and dependencies to other services state is appear. After that deadlocks started to show up.

I prepared example project to reproduce problem here.

Project contains two cases in which deadlock is reproduced and comparision with other rx implementations(RxSwift, Combine). RxSwift works similar. In Combine deadlocks not reproduced.

After click Reproduce deadlock1 or Reproduce deadlock2 and pause app execution, you see blocked threads:

deadlock

Also found this article described same problem.

May be we are using ReactiveKit incorrectly, and you have some suggestion?