Datastore emulator causes firebase admin to hang
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- python
调研方向
首先运行报告中的 datastore emulator 命令和提供的 Python 脚本,重点关注从 datastore_client.context() 到 auth.get_user_by_email() 的转换。比较移除三行 datastore context 后的行为。当 datastore emulator 运行时 Firebase Auth 查找正常返回,并且进程仍可中断,即表示完成。
由索引模型根据 Issue 内容生成。
描述
[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)
- 主要语言
- Python
- 星标
- 1.2k
- 派生
- 359
- 平均合并
- 5 天 6 分钟
- 30 天内合并 PR
- 2
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
firebase/firebase-admin-python 的其他 Issue
-
api: remoteconfig
难度 2/5 1-3 小时 新手友好度 75/100
firebase/firebase-admin-python#957 · 1 条评论 ·
-
api: database type: feature request
难度 2/5 1-3 小时 新手友好度 62/100
-
难度 4/5 3-5 天 新手友好度 45/100
firebase/firebase-admin-python#978 · 1 条评论 ·
-
[FR] Support VERIFY_AND_CHANGE_EMAIL in generate_email_action_link (parity with firebase-admin-node) 未关闭api: auth
firebase/firebase-admin-python#949 · 2 条评论 · 1 个 reaction · 已指派 1 人 ·
-
难度 4/5 3-5 天 新手友好度 43/100
firebase/firebase-admin-python#945 · 1 条评论 · 1 个 reaction ·
查看 firebase/firebase-admin-python 的全部 Issue
相似的 Issue
-
Add: hunch 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
AbdelStark/awesome-typesafe#104 ·
-
enhancement
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 68/100
DiamondLightSource/dodal#2211 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
openml/openml-python#1749 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
sipyourdrink-ltd/bernstein#6191 ·