firebase(firestore)/nodo.jsのerror【エラーまとめ】

プログラミング学習

firebaseなどのエラーまとめです。

凡ミスも一応初心者向けに残しています。メモ魔のため一部個人的な覚書もかねています。command + Fで検索してください。

目次

firebaseのエラー(error)

firebaseのよくあるエラーまとめです。

Uncaught (in promise) FirebaseError: Missing or insufficient permissions.(ブラウザのエラー)

Uncaught (in promise) FirebaseError: Missing or insufficient permissions.

firebaesのルールの設定がおかしいです。アクセス許可されていません。

もし許可しているはずなのに通らない場合は、usersがuserになっているなど、凡ミスがないか疑ってください。パスが1文字でも違うと当然通りません。

Function DocumentReference.set() called with invalid data. Unsupported field value: undefined (found in field xxx)

Function DocumentReference.set() called with invalid data. Unsupported field value: undefined (found in field xxx)

うっかりりミスでした。vue側から引数が渡っておらず未定義でした。

JsonProtoSerializer.push../node_modules/@firebase/firestore/dist/…

JsonProtoSerializer.push../node_modules/@firebase/firestore/dist/index.cjs.js.JsonProtoSerializer.fromRpcStatus

firebaseが期限切れになるとエラーがでました。このほかの原因でもこのようなエラーがでるかもしれませんが、期限切れかもしれない場合は期限切れを疑ってみましょう。ルールの変更することにより改善されます。

Firebase: Firebase App named ‘[DEFAULT]’ already exists (app/duplicate-app).

firebase.initializeAppが複数回呼ばれているらしい。

Uncaught ch {code: “auth/unauthorized-domain”, message: “This domain (XXX) is not authorized …se console -> Auth section -> Sign in method tab.”}

Uncaught ch {code: "auth/unauthorized-domain", message: "This domain (XXX) is not authorized …se console -> Auth section -> Sign in method tab."}

認証のエラーですね。ドメインの変更を行いませんでしたか。firebaseの管理画面から以下の操作を行ってください。

Authentication > ログイン方法 > ドメイン > ドメインの追加

This domainに書かれたドメインを追加します。

もしくはローカルホスト名が勝手に書き換わったときもこのエラーがでます。MacBook-2.local, MacBook-3.local といった名称に変更されているはずです。Mac側を修正しましょう。

システム環境設定 > 共有 > 名前を変更してenter

{code: “auth/invalid-credential”, message: “Error getting request token: 401 {“errors”:[{“code…://XXX.firebaseapp.com/__/auth/handler”}

{code: "auth/invalid-credential", message: "Error getting request token: 401 {"errors":[{"code…://XXX.firebaseapp.com/__/auth/handler"}

apiキーの再生成をしていませんか?apiキーでコケています。

Authentication > ログイン方法 > ドメイン > 該当サービスの鉛筆の編集アイコン

apiキーを確認し、間違っていたら入れなおしましょう。

FirebaseError: Function DocumentReference.set() called with invalid data. Unsupported field value: undefined (found in field

FirebaseError: Function DocumentReference.set() called with invalid data. Unsupported field value: undefined (found in field

つまらない単純エラーです。未定義の値を格納しようとしているため、削るか値がちゃんと入るようにしましょう。object内のundefinedもダメです。”空はokです。

updateの場合も同様です。

FirebaseError: Function DocumentReference.update() called with invalid data. Unsupported field value: undefined (found in field

FirebaseError: Invalid Query. A non-empty array is required for ‘array-contains-any’ filters.

FirebaseError: Invalid Query. A non-empty array is required for ‘array-contains-any’ filters.

arrayが渡っていないとか。arrayじゃない場合はarray-containsでok。

TypeError: set is not a function

TypeError: set is not a function

ドキュメントID(.doc)などの指定を疑いましょう。

Firestore backend. Backend didn’t respond within 10 seconds.

@firebase/firestore: Firestore (7.14.3): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.

ちょっと通信を絡む作業をしていたため、いったん全部そちらをコメントアウト→改善されませんでした。

vs codeを再起動→改善されませんでした。
pcの挙動も怪しく、たまたまmacも再起動したかったのでmacを再起動→改善されました。

深くは調べていないので、わかりませんが直近追加したプラグインなどもあれば疑ってもいいかもしれません。参考程度に。

This domain () is not authorized to…se console

Uncaught th {code: "auth/unauthorized-domain", message:
"This domain () is not authorized to…se console ->
Auth section -> Sign in method tab.",

firebaseにドメインを追加すれば解決ですね。

Authentification > ログイン方法 > ドメインを追加

Uncaught (in promise) FirebaseError: No document to update:

Uncaught (in promise) FirebaseError: No document to update:
Secure data access for users and groups  |  Firestore  |  Firebase

設定が間違ってるか、ローカルサーバーを立て忘れているか(Node.jsとExpressを利用したとき、立て忘れて適切なデータが入らずこけていたことがありました)、もしくはapiからデータ取得前にリダイレクトしていたとか(非同期処理になっていないか確認)。

“message”: “Permission denied. Could not perform this operation”

"message": "Permission denied. Could not perform this operation"

firebaseのルールの設定がされていません。firestoreとStorageのルールは各々の項目に各々ルールがあります。別設定ということです。

Could functionsを使う場合、Storageのルールを設定することが多いので、その場合、追加しましょう。

テストするなら、まず、こうですかね。

allow read: if true;

Error: Failed to get Firebase project XXX. Please make sure the project exists and your account has permission to access it.

firebaseのコマンドが効かない状態。長時間firebaseを使っていないとでるようです。セキュリティ対策でしょうか。

Error: Failed to get Firebase project XXX. Please make sure the project exists and your account has permission to access it.

ログアウト&ログインで解決です。

firebase logout && firebase login
スポンサーリンク

nodo.jsのサーバーサイドのエラー(error)

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client

凡ミス。res.send(‘テスト’)などを2回している文法エラー。eslintでも確認できます。

スポンサーリンク

その他のエラー(error)

Error occurred while trying to proxy request

[HPM] Error occurred while trying to proxy request //server/app from local:3000 to http://127.0.0.1:8080 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)[HPM] Error occurred while trying to proxy request //server/app from local:3000 to http://127.0.0.1:8080 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)

このエラーはプロキシを使ったときにでます。フロントエンドを立ち上げたとき、サーバーを起動していないか、間違った番号のポートで起動したかです。サーバーを起動していない場合、ターミナルをもうひとつ開き、

node app.js

みたいなコマンドでサーバーを起動しましょう。

スポンサーリンク

nuxt/vuex/vue/firebase/typescriptの動画教材など

nuxt/vuex/vue/firebase/typescriptの動画教材や書籍教材はこちらの記事にまとめてあります。

ご参考になれば幸いです。

コメント