firebase / firebase/firebase-tools

Firestore emulator exec should wait for import to complete before executing script

Open
#4,331 2 comments 1 reaction 0 assignees View on GitHub
emulator-suite emulators: firestore internal-bug-filed type: feature request
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

### [REQUIRED] Environment info

**firebase-tools:** 10.2.2

**Platform:** macOS

### [REQUIRED] Test case

It is too complicated to provide a test case because it requires uploading a lot of data. The issue is the following:
If you have a large import database (~0.5GB - this isn't even that big) then the emulator takes ~30s or so on my machine before I can 1) view the data in the emulator UI and 2) read/write to the DB. My requests to get or write documents just hang until this initialization is complete.

If you run emulator exec and then a script that writes to the DB, I am getting DEADLINE_EXCEEDED errors because the DB is not initialized yet as it is still processing the imported data.

### [REQUIRED] Steps to reproduce

See above

### [REQUIRED] Expected behavior

It should wait for the DB to finish initializing before running any exec script

### [REQUIRED] Actual behavior

DEADLINE_EXCEEDED error occurs because the script after emulator exec is trying to write to a document before the DB is initialize.

I confirmed that this is the issue by instead just starting the emulator in a separate terminal and then:
1. attempting to run the same script from the exec command immediately - it gives me a deadline exceeded error before i can view the data in the UI
2. attempting to run the same script from the exec command after the UI shows the data in the DB - the script runs fine and is able to read and write to the db

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.