Can't catch exception from firebase promise

I’m not sure whether this is a problem with firebase or whether something is happening behind the scenes in expo in regards to connectivity.

I have the follow function

var docRef = firebase.firestore().collection("users").doc(user.uid);
docRef.get()
.then(() => {
     //function logic here
})
.catch(error => {
    alert('Unable to get records, Please ensure you are connected to the internet')
})

The problem is that when I click my function to get the record when I’m not connected to the internet (I’m just turning this off once inside the app for now). The function isn’t returning that alert at all.

This is intermittent by the looks of it aswell. Sometimes when I load the app, I will find that it will sometimes catch the error and sometimes not. However even when it catches the error, it can take a very long time.

Anyone have any ideas what could be going wrong?

Edit:

Okay I’ve found that I am misunderstanding what the then and catch statements are doing. I thought that it would attempt to grab the user information, and use a catch statement if it failed due to no internet. Upon further investigation I now realise that having no internet is not an error.

Is there any other way in expo to preform this task and alert the user if they are not connected to the internet?

Thanks

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.