Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react native setTimeout Android warning #173

Open
bojidaryovchev opened this issue Jul 18, 2021 · 0 comments
Open

react native setTimeout Android warning #173

bojidaryovchev opened this issue Jul 18, 2021 · 0 comments

Comments

@bojidaryovchev
Copy link

Hello there, I saw the discussion here expo/examples#209 and that the implementation around handling refresh tokens with Expo is still foggy so I turned to your library. I successfully plugged it in my react native project however I am getting the following warning:

Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module awake, and timers can only be called when the app is in the foreground. See facebook/react-native#12981 for more info.

which comes from this piece of code:

  setTimeout(() => {
      let refreshTokenData = data;
      if (token.refresh_token) {
          refreshTokenData = {
              ...data,
              refresh_token: token.refresh_token,
              grant_type: "refresh_token",
          };
      }
      fetchAccessToken(refreshTokenData, domain, setAccessToken, setUser, onTokenRequestFailure);
  }, token.expires_in * 1000 - requestNewAccessTokenBuffer);

I found out that I can suppress the warning using LogBox.ignoreLogs(['Setting a timer for a long period of time']); however I am not sure that would be the right way to go so I wanted to ask for your expertise on the matter as to what would the best approach be. Regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant