centrifuge-js icon indicating copy to clipboard operation
centrifuge-js copied to clipboard

Warning about timers on React Native

Open alexsegura opened this issue 3 years ago • 5 comments

Related to facebook/react-native#12981

Capture d’écran 2021-09-02 à 14 44 40

alexsegura avatar Sep 02 '21 12:09 alexsegura

@alexsegura hello, could you explain what should be addressed here by centrifuge-js?

FZambia avatar Sep 02 '21 13:09 FZambia

Hi @FZambia sorry for the poorly detailed issue 😔

I haven't read centrifuge-js code, but I guess the JavaScript runtime could be detected, and the (default) timeout value could be set accordingly?

alexsegura avatar Sep 02 '21 14:09 alexsegura

I think it's there no?

https://github.com/centrifugal/centrifuge-js/blob/7b70bf21007ae39e79069e9e938c0d5aa1b97718/src/centrifuge.js#L1208-L1211

alexsegura avatar Sep 02 '21 14:09 alexsegura

I haven't read centrifuge-js code, but I guess the JavaScript runtime could be detected, and the (default) timeout value could be set accordingly?

What do you mean by setting default timeout?

Looking at screenshot you provided your tokens expire In one hour. In this case centrifuge-js sets timer for one hour to refresh token after that. Do you have any specific fix for React Native warning in mind?

Also, did you experience any problems with client behavior?

FZambia avatar Sep 02 '21 14:09 FZambia

In general, as your application goes to background you should not keep connection active. This is a common thing on mobile devices since they do not guarantee connection stability while app in background. So token refresh timer should be cleaned up upon disconnecting and going to background.

I never worked with React Native personally though, correct me if I am missing sth.

FZambia avatar Sep 02 '21 15:09 FZambia