Codesandbox-client: [ERROR] Firebase initializeapp() not working on loading multiple times

Created on 20 Dec 2017  路  5Comments  路  Source: codesandbox/codesandbox-client

Problem

I have been trying this - https://codesandbox.io/s/w0nvzjy218 in my desktop with local server. It's been working fine.

But when I moved it to codesandbox platform, on multiple refreshing/loading it crashes as two types of error occur simultaneoulsy.

  1. Firebase: Firebase App named '[DEFAULT]' already exists (app/duplicate-app)

scr1codesand

  1. When I resolve 1st issue then, ANOTHER ERROR - FIREBASE FATAL ERROR: Can't determine Firebase Database URL. Be sure to include databaseURL option when calling firebase.intializeApp().

And I continue solving these issue one after the another as they happen in recursive manner.

Also if you change config in your way, there is response though config is wrong. There is some real issue here with firebase with implementing it with firebase

Thanks for incredible platform!

馃悰 Bug

Most helpful comment

Quick hack is firebase stores initializations in apps array

Can work around it doing:

if(!firebase.apps.length){
    firebase.initializeApp(config);
}

not likely a good production approach but prevents having to refresh for every change in the sandbox

All 5 comments

Heya! You hit a good point: our HMR doesn't work well yet with stateful applications (like with a firebase config). We're working on fixing this here: #313. For now the thing to make it work is to reload the browser window everytime.

I want to work on this issue some more the coming weekend, do you perhaps have a GitHub repo of the project as a real-world test application for CodeSandbox?

@CompuIves No, I don't have the github repo that as I am currently working on that real-world application but I have sandbox - https://codesandbox.io/s/w0nvzjy218 .

Since you said that - for now reloading browser window is the only hack, then I'll keep up with that. Thanks

Quick hack is firebase stores initializations in apps array

Can work around it doing:

if(!firebase.apps.length){
    firebase.initializeApp(config);
}

not likely a good production approach but prevents having to refresh for every change in the sandbox

@charlietfl I tried that also, but after one or two attempts, it started showing that error again.

You can now configure your sandbox to do a full reload by creating a sandbox.config.json, that should fix this issue!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mescalito picture mescalito  路  65Comments

Nico-L picture Nico-L  路  21Comments

gautamarora picture gautamarora  路  50Comments

CompuIves picture CompuIves  路  26Comments

Saeris picture Saeris  路  115Comments