-
Notifications
You must be signed in to change notification settings - Fork 54
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
Potential memory leak in services/api/index.ts #21
Comments
I don't know if I'm missing something but |
Uh everything's changed 😳 |
Updated the link. The source was restructured into the |
And yes, I saw the const checkNetworkState = async () : Promise<boolean> => {
const networkState = await NetInfo.fetch();
return networkState.isInternetReachable && networkState.isConnected;
};
const connected = async () : Promise<boolean> => {
if (!(await checkNetworkState())) {
await new Promise(r => setTimeout(r, 1000));
if (!(await checkNetworkState()))
throw new Error('Network unavailable');
}
return true;
}; |
Thank you |
Certainly! |
In the
connected
function inhttps://github.com/covidgreen/covid-green-app/blob/current/services/api/index.ts#L47-L60https://github.com/covidgreen/covid-green-app/blob/current/src/services/api/index.ts#L46-L59, whenretry
istrue
and the network is not available, the function recursively awaits on itself. This sets up a memory leak when the network is unavailable for a protracted period of time (memory leak in that the Promise chain will grow indefinitely while waiting for the network to become available.The code in question is copied below:
This should be refactored to avoid the recursion.
The text was updated successfully, but these errors were encountered: