Firestore Emulator Bug: Data Writes Succeed But Nothing Shows Up (Solved)


🧪 What Happened

The Setup

  • Used a single Firebase project for both production and development
  • Ran Firestore locally with the Emulator Suite
  • Used local-only mode to avoid writing to production
  • Everything worked: writes, reads, rules, etc.

⚐️ The Shift

  • Split Firebase into:

    • A production project
    • A separate dev project for local testing

Motivation: Emulator Suite doesn’t support everything; separation avoids conflicts with production


😤 The Problem

  • Firestore writes succeeded:

    • ✅ Green checks in Emulator UI Requests tab
    • ✅ No rule violations
  • But Firestore Data tab was empty:

    • No /users, /words, or new documents

Yet logs showed:

create /databases/(default)/documents/users/UID/words/term|lang
update /databases/(default)/documents/users/UID/words/term|lang

Diagnosis

🔍 The Root Cause

  • Emulator UI only shows the Firestore DB for the default project set in Firebase CLI

  • If CLI context is set to a different (old) project:

    • Emulator writes go to one DB
    • UI reads from another
    • ❌ Data mismatch

The Fix: Set the Correct Default Project

✅ Step-by-step

  1. Open terminal in your project folder

  2. Add a project alias:

    firebase use --add
    
  3. Enter an alias (e.g., dev)

  4. Set it as default:

    firebase use dev
    
  5. Restart the emulator:

    firebase emulators:start
    

Now UI shows the correct database: /firestore/data/databases/(default)/documents

🔧 Optional: Set Default in .firebaserc

Update .firebaserc:

{
  "projects": {
    "default": "your-dev-project-id"
  }
}

Prevents accidental CLI context mismatch.


Conclusion

If writes succeed but no data appears:

  • You’re likely writing to one project while UI reads another

Solution

firebase use <project-alias>
firebase emulators:start

🤀 TL;DR

Symptom Fix
Writes succeed but no data shows Run firebase use <your-dev-alias>
UI still empty Check UI shows correct project DB
Want to persist config Edit .firebaserc and set "default"

Happy emulating 👨‍💻🔥