question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@firebase/database: FIREBASE WARNING: Exception was thrown by user callback. TypeError: Cannot read property 'myID' of undefined

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:33

github_iconTop GitHub Comments

19reactions
mubashshirulcommented, Jun 4, 2018

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

5reactions
safarmercommented, May 15, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FIREBASE WARNING: Exception was thrown by user callback ...
When I first edit a post and after that delete the same post, it deletes from both back and and front end, seemingly...
Read more >
FIREBASE WARNING: Exception was thrown by user callback ...
Why I am confident that data is at fault. Your error message was: TypeError: Cannot read properties of undefined (reading 'AccountStatus'). This means...
Read more >
Firebase Database REST API
Use this to limit how long the read takes on the server side. If a read request doesn't finish within the allotted time,...
Read more >
an error was thrown in afterall cannot read property - You.com
An error was thrown in afterAll TypeError: Cannot read property 'ids ... ... This is one of potential fixes as your error suggest...
Read more >
FirebaseUI for Web — Auth - Firebase Open Source
FirebaseUI Auth provides a drop-in auth solution that handles the UI flows for signing in users with email addresses and passwords, phone numbers, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found