rocicorp/replicache-old

Prevent reentrancy in Flutter SDK

Closed this issue · 3 comments

arv commented

A transaction should not be able to open another transaction. This can happen if the tx function references a Replicache object.

In a non async world this could be detected by checking the call stack. In an async world this can be done using Zones. Zones was also ported to Angular but it does require a bunch of monkey patches. See https://blog.strongbrew.io/how-the-hell-do-zones-really-work/

Maybe we can achieve this by passing around enough context to all the transactions?

I don't see how we can do that and make it foolproof. If you do can you provide an example?

I definitely don't want to monkey-patch anything in a user's environment (*shivers remembering onclick).

IIRC the alternative to zones was to detect iloops trying to land transactions. You already created a bug for this. So if you implement that bug, then the zone thing is just a nicer dx on top of that in environments we can do it.

arv commented

I don't see how we can do that and make it foolproof. If you do can you provide an example?

I don't know why I keep resetting my brain on this problem?