Firebase 模拟器无法以无意义的错误启动

Firebase emulators fail to start with meaningless error

我们使用模拟器已有一段时间了。突然,他们停止了在两个开发人员(但不是所有开发人员)的机器上工作。他们尝试调用 firebase emulators:start,然后收到以下错误消息:Error: An unexpected error has occurred.

我们真的不知道为什么会这样。我们甚至尝试重做 firebase init 和 emulators init。到目前为止,我们所做的一切都无济于事。这是更多详细信息的控制台输出:

➜  firebase git:(dev-vab) ✗ firebase emulators:start
i  emulators: Starting emulators: functions, firestore, database, hosting, pubsub
⚠  functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth
⚠  Your requested "node" version "10" doesn't match your global version "14"
i  firestore: Firestore Emulator logging to firestore-debug.log
i  database: Database Emulator logging to database-debug.log
i  hosting: Serving hosting files from: public
✔  hosting: Local server: http://0.0.0.0:5000
i  pubsub: Pub/Sub Emulator logging to pubsub-debug.log
i  ui: Emulator UI logging to ui-debug.log
i  functions: Watching "/Users/isaacmartin/git_repos/firebase/functions" for Cloud Functions...
✔  functions[updateUser]: firestore function initialized.
✔  functions[handleEventInviteeCreation]: http function initialized (http://0.0.0.0:5001/likemindedly-stage/us-central1/handleEventInviteeCreation).
i  emulators: Shutting down emulators.
i  ui: Stopping Emulator UI
⚠  Emulator UI has exited upon receiving signal: SIGINT
i  functions: Stopping Functions Emulator
i  hosting: Stopping Hosting Emulator
i  database: Stopping Database Emulator
i  firestore: Stopping Firestore Emulator
i  pubsub: Stopping Pub/Sub Emulator
i  hub: Stopping emulator hub
i  logging: Stopping Logging Emulator

Error: An unexpected error has occurred.

Having trouble? Try again or contact support with contents of firebase-debug.log

现在,您会注意到我们确实检查了调试日志并发现了以下可能相关的内容:

[debug] [2020-10-22T22:06:39.394Z] 15:06:39.394 [FirebaseWorkerPool-1-2] WARN com.firebase.core.namespace.NamespaceActorSystem - Request for ns: likemindedly-stage has incorrect domain. Current domain: 0.0.0.0, expected domain: firebaseio-staging.com
 {"metadata":{"emulator":{"name":"database"},"message":"15:06:39.394 [FirebaseWorkerPool-1-2] WARN com.firebase.core.namespace.NamespaceActorSystem - Request for ns: likemindedly-stage has incorrect domain. Current domain: 0.0.0.0, expected domain: firebaseio-staging.com\n"}}
[debug] [2020-10-22T22:06:39.448Z] <<< HTTP RESPONSE 404 {"content-length":"231","content-type":"application/json; charset=utf-8","access-control-allow-origin":"*","cache-control":"no-cache"}
[debug] [2020-10-22T22:06:39.448Z] <<< HTTP RESPONSE BODY {
  "correctUrl" : "https://likemindedly-stage.firebaseio-staging.com",
  "error" : "Namespace likemindedly-stage lives in a different region. Please change your database URL to https://likemindedly-stage.firebaseio-staging.com"
}

这似乎是在抱怨我们在配置中指向本地模拟器,但不清楚为什么这会成为问题?

几个小时前我也遇到了这个问题。当我从 firebase.json 中删除主机时,它允许我正常启动模拟器,但我还没有弄清楚到底是什么导致了错误或如何在 json 之外正确设置主机文件.

解决此问题的另一种方法是将新的 firebase 身份验证模拟器添加到您的模拟器套件中。