Datastore emulator causes firebase admin to hang
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- python
- Domain
- authentication, databases
Research direction
Start by running the datastore emulator commands from the report and the provided Python script, focusing on the transition from datastore_client.context() to auth.get_user_by_email(). Compare behavior with the three datastore context lines removed. Done means the Firebase Auth lookup returns normally while the datastore emulator is running, and the process remains interruptible.
Written by the indexing model from the issue text.
Description
[REQUIRED] Step 2: Describe your environment
- Operating System version: Mac 14.5
- Firebase Product: firebase-admin==6.2.0 and firebase-admin==6.5.0
- Python version: 3.11.4
- Pip version: 24.0
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
This problem started around June 1. Before, I have been doing this for several years without any issues.
The problem is that auth.get_user_by_email() freezes and it is caused by some interaction with running the cloud datastore emulator locally. This happens with either the older emulator (gcloud beta emulators datastore start) or the newer one (gcloud emulators firestore start ). I have tried downgrading gcloud and two versions of firebase-admin listed above.
Run the script below. At auth.get_user_by_email(), the script hangs indefinitely with no output. You can't even ctrl-c to stop the script. You need to kill -9 in a separate terminal window.
If you comment out the three lines starting with with datastore_client.context():, then auth.get_user_by_email() works.
Since the code just freezes, I am at a loss as to how to debug.
Relevant Code:
import os
from google.cloud import ndb
import firebase_admin
from firebase_admin import auth, initialize_app
print('starting')
class User(ndb.Model):
email = ndb.StringProperty(required=True)
os.environ['DATASTORE_DATASET'] = 'my-project'
os.environ['DATASTORE_EMULATOR_HOST'] = 'localhost:8081'
os.environ['DATASTORE_EMULATOR_HOST_PATH'] = 'localhost:8081/datastore'
os.environ['DATASTORE_HOST'] = 'http://localhost:8081'
os.environ['DATASTORE_PROJECT_ID']= 'my-project'
datastore_client = ndb.Client('my-project')
if not firebase_admin._apps:
initialize_app()
email = 'me@example.com'
with datastore_client.context():
user = User.get_by_id(email)
print(user)
# This hangs and you can't even ctrl-c to stop.
# Works if datastore client stuff is commented out.
fb_user = auth.get_user_by_email(email)
print(fb_user)
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 359
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from firebase/firebase-admin-python
-
api: remoteconfig
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
firebase/firebase-admin-python#957 · 1 comment ·
-
api: database type: feature request
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
firebase/firebase-admin-python#978 · 1 comment ·
-
[FR] Support VERIFY_AND_CHANGE_EMAIL in generate_email_action_link (parity with firebase-admin-node) Openapi: auth
firebase/firebase-admin-python#949 · 2 comments · 1 reaction · 1 assignee ·
-
Difficulty 4/5 3-5 days Newbie friendliness 43/100
firebase/firebase-admin-python#945 · 1 comment · 1 reaction ·
All issues in firebase/firebase-admin-python
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
canonical/paas-charm#368 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
tech debt
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
StevenBlack/hosts#3256 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
qualcomm/qai-appbuilder#275 ·