-1

Firebase Emulator starts 3 seperate Realtime Databases. I've never added configurations for multiple and until today it never created more than one. Now I can't get firebase to start just one. This seems like a bug, there are multiple other questions on the topic but no one seems to know what the bug is.

Here's my firebase.json file:

{ "database": {
    "rules": "database.rules.json"
  },
  "functions": [
    {
      "source": "functions",
      "codebase": "default",
      "ignore": [
        "node_modules",
        ".git",
        "firebase-debug.log",
        "firebase-debug.*.log"
      ]
    }
  ],
  "emulators": {
    "auth": {
      "port": 9099
    },
    "database": {
      "port": 9000
    },
    "ui": {
      "enabled": true
    },
    "singleProjectMode": true
  }
}

And here's my .firebaserc:

{
  "projects": {
    "default": "MyProject-development"
  }
}

Screenshot of emulator

Update: Randomly the project just started working correctly, then went back to presenting multiple realtime databases and now it has reverted back to working correctly. I think it's a caching problem.

Update 2: Randomly the project just stopped working correctly again. Everything is leading me to believe this is some sort of caching issue.

WikipediaBrown
  • 689
  • 1
  • 8
  • 27
  • 1
    How are you setting this up? Do you have a repro or links to these issues? Ive used the emulators with Firestore so I can't relate but there's not much here to work off. – Phix Aug 21 '23 at 01:47
  • Legitimately it just fixed itself. I'm thinking that the cli is caching info from previous runs. I'll put my setting up in a sec but to be fair, I ended up asking this question mostly to vent about the consistency shoddy behaviors of Google software and the consistently haughty attitudes of Google engineers. – WikipediaBrown Aug 21 '23 at 07:01

1 Answers1

0

So I just figured it out. Adding a "database" section to the top level of the firebase.json file makes the emulator create 2 databases. Additionally, if the name of the project in .firebaserc starts with demo AND there's a "database" section added to the top level of your firebase.json file then there will be 3 total Realtime Databases created.

So, having a firebase.json file that looks like this:

{ "database": {
    "rules": "database.rules.json"
  },
  "functions": [
    {
      "source": "functions",
      "codebase": "default",
      "ignore": [
        "node_modules",
        ".git",
        "firebase-debug.log",
        "firebase-debug.*.log"
      ]
    }
  ],
  "emulators": {
    "auth": {
      "port": 9099
    },
    "database": {
      "port": 9000
    },
    "ui": {
      "enabled": true
    },
    "singleProjectMode": true
  }
}

and a .firebaserc file that looks like this:

{
  "projects": {
    "default": "demo-MyProject-development"
  }
}

results in 3 databases being created.

I've decided that that I'm going to go without adding the rules file to my firebase.json (thus removing the "database" section from the file) and writing the rules manually into the browser.

My files now look like this:

firebase.json

{ 
  "functions": [
    {
      "source": "functions",
      "codebase": "default",
      "ignore": [
        "node_modules",
        ".git",
        "firebase-debug.log",
        "firebase-debug.*.log"
      ]
    }
  ],
  "emulators": {
    "auth": {
      "port": 9099
    },
    "database": {
      "port": 9000
    },
    "ui": {
      "enabled": true
    },
    "singleProjectMode": true
  }
}

.firebaserc

{
  "projects": {
    "default": "MyProject-development"
  }
}

WikipediaBrown
  • 689
  • 1
  • 8
  • 27
  • Interesting, so if the name doesn't start with "demo" the replication doesn't happen? – Phix Aug 21 '23 at 17:08
  • One of the replications won't happen. One of the three in the screenshot is related to adding demo, another one is related to adding the access rules. That said, I'm still seeing 2 no matter what I do today. I just deleted firebase tools and now I'm reinstalling it and seeing what that does. I'll update when I can get some more insight. I'm thinking it has something to do with the Java runtime that the emulator runs on but I don't know yet. – WikipediaBrown Aug 22 '23 at 00:53