@firebase/database: FIREBASE WARNING: Exception was thrown by user callback. TypeError: Cannot read property 'myID' of undefined
gate3 opened this issue · comments
Version info
Angular: ^5.2.0
Firebase: ^4.13.1
AngularFire: ^5.0.0-rc.6.0
Other (e.g. Node, browser, operating system) (if applicable): Firebase Hosting
Test case
getLocations(radius: number, coords: Array<number>) {
this.geoFire.query({
center: coords,
radius: radius
})
.on('key_entered', (userKey, location, distance) => {
const existAlready = this.hits.value.filter(h=>h.userKey === userKey)
if(existAlready.length > 0){
return
}
const u = this.userList.query.ref
.child(`/${userKey}`)
.on('value',s=>{
const {name, address} = s.val()
console.log(s.val())
let hit = {
location,
distance,
name,
address,
userKey
}
let currentHits = this.hits.value
currentHits.push(hit)
this.hits.next(currentHits)
this.eventService.sendMessage(Constants.EVENT_MESSAGES.LOADING, true)
})
})
}
Basically what i am doing is fetching the current location and passing it to the function above
Steps to reproduce
I am using angularfire with geofire for a location based app for fetching locations around my user. It works perfectly on my dev machine, but as soon as i build and deploy to firebase hosting, I get a very strange error
@firebase/database: FIREBASE WARNING: Exception was thrown by user callback. TypeError: Cannot read property 'myID' of undefined
What i am doing basically is fetching the current location and passing it to the function above, the function is meant to fetch nearby locations and then put them in a behavioursubject. It works well in development like a said, but its a big NO NO on the firebase hosting server.
Expected behavior
I expect to get back the locations around me saved in firebase.
Actual behavior
I am getting an error as stated above.
I am having the same issue as well! In dev the code runs fine, once I switch to ng build --prod
i get the following message when i run the app Cannot read property 'myID' of undefined
same here
same here
same here!
same here. Is the fix planned down the line?
same here
I ran into this issue today and it seemed to be related to having a logged in Firebase auth state. I pushed the same code to two different Firebase hosting projects and it worked on one and not the other. The site that worked was logged out. Once I clear cookies etc for the broken site and logged in again it started working.
Same problem for me, it throws the error for some users, and works for some other users.
same here. works for the first time but when I close the browser and open the hosted site I get this error.
Is there any update from the Firebase team on this?
No, i posted the issue at stackoverflow and no answers from anyone.. how can we open a bug at firebase?
https://stackoverflow.com/questions/50402963/firebase-database-exception-was-thrown-by-user-callback-typeerror-cannot-rea
I think we should close this issue, since it not problem from angularfire, it is firebasejs sdk
Not sure how you can be sure it's not a problem with angularfire as the people reporting it all seem to be using angular - or at least I can't find others experiencing this problem. I'm seeing the same problem as everyone else, only when compiled with --prod.
I'm getting the same exception but only when I'm trying to access my website from my workplace proxy. At home I can connect without any issues.
Same here. --prod app throws this error. I see that in chrome incognito mode it works fine.
I found a workaround : https://stackoverflow.com/questions/50402963/firebase-database-exception-was-thrown-by-user-callback-typeerror-cannot-rea
But it doesn`t explain the main problem.
Same problem ..
I am having the same issue as well! In dev the code runs fine, once I switch to ng build --prod i get the following message when i run the app Cannot read property 'myID' of undefined
Same issue here, it seems that if you delete Firebase's cookies it will work, however once those are available it just starts spitting the error. Maybe that's why many people reported it as an issue which is not always easily reproducible.
@angelnikolov, That is true. The issue is affecting only the system of the developers (presumably) who have ping the application from a dev environment (thereby creating the login cookie) and then try to access them from a prod env. To avoid this issue, one can clear the cookies and hitting the prod env. Or just give it to your tester or manager who aren't using the dev env. It will work for them. Either ways, this is still and issue and needs attention from the angularfirebase, Not a P1 though.
I have solved this issue. Just do this in your app.component.ts
constructor() {
localStorage.removeItem('firebase:previous_websocket_failure');
}
This is a temporary solution, on network fluctuation it will throw same error
Ths same problem with already bundled (--prod) and deployed to hosting app. After weeks of work has eventually crashed with this error.
@mubashshirul Thank you! Worked like a charm
@mubashshirul 's solution worked good, but error sporadically appeared not only on developer but on clients' computers too. Now after using ng build --prod --build-optimizer=false
everything is OK for more than a week.
Has this problem been resolved? (other than removing firebase data from localStorage)
Same Issue here, is there a final solution from the firebase team?
Same here with:
@angular 5.2.11
angularfire2 5.0.0-rc.7
firebase 4.13.1
After network disconnection and later reconnection, error starts popping up, and gathered data cannot be sent to Firebase anymore. As @mubashshirul says, proposed solution doesn't work for network outages.
Downgrading to firebase#4.12.1
seems to solve the problem
I Experienced the same problem as @aroncal . At first, I thought it was a problem related to the user login token timing out, but no, it seems to be network disconnect and reconnect related. I will try to downgrade to firebase#4.12.1
myself and see if it works
EDIT
I was not able to build my application when downgrading from firebase:^5.5.7
to firebase:4.12.1
, so I cannot confirm if it works or not
No official fix for this yet? It's still alive even on a wrong GitHub project, since the problem is apparent when using only the JS Database / library.
@mubashshirul 's solution worked good, but error sporadically appeared not only on developer but on clients' computers too. Now after using
ng build --prod --build-optimizer=false
everything is OK for more than a week.
This is working to our case. in our case removing the localstorage item didn't help.
I changed from ng build --prod --aot --build-optimizer
to ng build --prod --aot --build-optimizer=false
Why this issue is closed if now on 2021 is still occurring with --prod devices?