#firebase #firebase-cli
#огневая база #firebase-cli #firebase
Вопрос:
Мы уже некоторое время используем эмуляторы. Внезапно они перестали работать на машинах двух разработчиков (но не всех разработчиков). Они пытаются вызвать firebase emulators:start
и затем обрабатываются следующим сообщением об ошибке: Error: An unexpected error has occurred.
Мы действительно понятия не имеем, почему это происходит. Мы даже пытались повторить инициализацию firebase и инициализацию эмуляторов. До сих пор ничего из того, что мы пробовали, не помогло. Вот вывод консоли для более подробной информации:
➜ 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.comn"}}
[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"
}
Похоже, он жалуется на то, что мы указываем на локальные эмуляторы в нашей конфигурации, хотя непонятно, почему это может быть проблемой?
Ответ №1:
Я также столкнулся с этой проблемой, начавшейся всего несколько часов назад. Это позволило мне запустить эмуляторы в обычном режиме, когда я удалил хосты из своего firebase.json, но я не понял, что именно вызывает ошибку или как правильно настроить хосты вне файла json.
Комментарии:
1. Я на самом деле только что понял это сам и пришел на SO, чтобы опубликовать ответ. Я думаю, что что-то изменилось
firebase-tools
. Крайне неприятно.2. После просмотра firebase summit я думаю, что эта проблема возникла, когда они начали добавлять аутентификацию в пакет эмуляторов firebase до того, как он был официально включен. Это должно быть решено сейчас.
3. У меня была такая же проблема, и ваши комментарии помогли мне. Я понизил свой глобальный пакет firebase-tools
npm install -g firebase-functions@8.11.0
до более низкой версии, и он снова работал так, как ожидалось.
Ответ №2:
Другой способ решить эту проблему — добавить новый эмулятор аутентификации firebase в ваш набор эмуляторов.