supertokens / supertokens-react-native

React Native SDK for SuperTokens
Other
28 stars 11 forks source link

InteractionManager.runAfterInteractions() for releasing internal locks is risky #106

Closed melvynhills closed 1 year ago

melvynhills commented 1 year ago

While investigating why all our fetch requests were not being sent after a few minutes, I realised SuperTokens locking mechanism uses InteractionManager.runAfterInteractions() to release locks.

I fixed our issue by making sure our long-running looping animations use isInteraction: false.

But couldn't requestAnimationFrame() or setImmediate() be used instead? In my opinion, InteractionManager.runAfterInteractions() should not be used for low-level/data/core libraries unrelated to animations.

nkshah2 commented 1 year ago

Hi @melvynhills

Thanks for the issue, can you elaborate on why you consider InteractionManager.runAfterInteractions() risky?

melvynhills commented 1 year ago

I find it risky in the sense that users of the library don't expect anything related to animations to potentially pause or even block any token-related logic. It took me personally multiple days to track why no network call would fire on our side.

What is the intended goal of using InteractionManager.runAfterInteractions()? IMHO using setImmediate() would be more appropriate here, but I might miss something.

nkshah2 commented 1 year ago

Would you be open to raising a pull request to fix this?

nkshah2 commented 1 year ago

Closing this since this has been reolves in 4.0.6, thanks again for the contribution!