On my PWA, there is some functions running by onCall functions. It was working properly, but some days ago any of these functions is returning "Firebase error: internal" only when the PWA is running on a mobile with 4g network. In a Wifi network everything is working as expected.
Some extra informations:
My code - Web:
async checkFirstLogin(uid) {
this.apiPortal = this.functions.httpsCallable('apiPortal')
let body = {
action: 'checkFirstLogin',
uid: uid
}
return this.apiPortal({body: body})
.then((response) => {
return response.data.success
}).catch((e) => {
console.log('========> Error', e) //returns "Firebase error: internal"
})
}
My Code - function
const admin = require('firebase-admin');
const functions = require('firebase-functions');
try {
admin.initializeApp();
} catch (e) {}
const runtimeOpts = {
timeoutSeconds: 60,
memory: '2GB'
}
exports.default = functions.region('southamerica-east1').runWith(runtimeOpts).https.onCall((data, context) => {
if (!context.auth) {
return {
status: 'error',
code: 401,
message: 'Not signed in'
}
}
functions.logger.log(`#apiPortal - starting - action:${data.body.action}`)
if (data.body.action==='checkFirstLogin') {
let ref = admin.database().ref(`login/${data.body.uid}`)
return ref.once('value').then((data) => {
if (data.val()) {
let usr = data.val()
return {success: true, data: usr.hasOwnProperty('last_login')}
} else {
return {success: true, data: null}
}
}).catch((e) => {
throw new functions.https.HttpsError('Unknown error', e.message, e)
})
} else {
return {success: false, data: null}
}
}
})
We found that the problem is specifically with TIM 4g network. It s a DNS problem of them that do not resolve the url of our API in GCP. Today, after 3 days of problems, it's working again