protobufjs.loadProtoFile for 'google/firestore/v1beta1/firestore.proto' always fails due to this file missing in the published versions (tested with 4.6.0 and 4.6.1).
I'm able to reproduce consistently with this code in a fresh repo after running yarn add firebase:
const firebase = require('firebase');
require('firebase/firestore');
const customToken = '...';
firebase.initializeApp({
apiKey: '...',
projectId: '...',
});
firebase.auth().signInWithCustomToken(customToken);
db.collection('test').doc('1234').get().then((doc) => {
console.log('doc', doc);
});
This causes the following:
Firestore (4.6.1) 2017-11-08T01:51:23.677Z: INTERNAL UNHANDLED ERROR: Error: Failed to fetch file
at /Users/justin/test/node_modules/protobufjs/dist/protobuf.js:5164:30
at ReadFileContext.callback (/Users/justin/test/node_modules/protobufjs/dist/protobuf.js:358:29)
at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:420:13)
(node:81214) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Failed to fetch file
Attempts to make requests after this fail with:
Error: FIRESTORE (4.6.1) INTERNAL ASSERTION FAILED: AsyncQueue is already failed: Failed to fetch file
at Object.fail (/Users/justin/test/node_modules/@firebase/firestore/dist/cjs/src/util/assert.js:35:11)
at AsyncQueue.schedule (/Users/justin/test/node_modules/@firebase/firestore/dist/cjs/src/util/async_queue.js:41:22)
at FirestoreClient.listen (/Users/justin/test/node_modules/@firebase/firestore/dist/cjs/src/core/firestore_client.js:267:25)
at DocumentReference.onSnapshotInternal (/Users/justin/test/node_modules/@firebase/firestore/dist/cjs/src/api/database.js:564:54)
at /Users/justin/test/node_modules/@firebase/firestore/dist/cjs/src/api/database.js:574:34
at new Promise (<anonymous>)
at DocumentReference.get (/Users/justin/test/node_modules/@firebase/firestore/dist/cjs/src/api/database.js:573:16)
at repl:1:16
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at REPLServer.defaultEval (repl.js:240:29)
Specifically it looks like https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore/src/platform_node/load_protos.ts#L46-L50 is trying to load a file that would be in /Users/justin/test/node_modules/@firebase/firestore/dist/cjs/src/protos for example but this directory doesn't exist, though it does here: https://github.com/firebase/firebase-js-sdk/tree/master/packages/firestore/src. The only protos directory I can find is here:
~/test$ find . -name protos
./node_modules/@google-cloud/firestore/protos
Hmmm this issue does not seem to follow the issue template. Make sure you provide all the required information.
I have the same isssue when I tries to use take(1) query for my Serverside Rendering App (angular universal), I try to reinstall but it still the same problem. Don't know what to do
I ran into this problem because:
I fixed it after finding it in Node docs on https://cloud.google.com/firestore/docs/quickstart
/** deprecated **/
const Firestore = require('@google-cloud/firestore');
const config = {
apiKey:
authDomain:
projectId:
};
const t = new Firestore(config);
export default t;
/** browser, not server **/
const firebase = require("firebase");
require("firebase/firestore");
firebase.initializeApp({
apiKey: '### FIREBASE API KEY ###',
authDomain: '### FIREBASE AUTH DOMAIN ###',
projectId: '### CLOUD FIRESTORE PROJECT ID ###'
});
var db = firebase.firestore();
export db;
/** working **/
const admin = require('firebase-admin');
const serviceAccount = require("/my-service-credentials.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
});
const db = admin.firestore();
export default db;
@dzjin the problem is specifically with the firebase-js-sdk library, the firebase-admin library indeed works correctly.
I used the former because I wanted to test out client behavior around authenticating with custom tokens and then making queries on data to test permission rules. I had to run the test in a browser instead of in a node console due to this issue.
I have a question: if I'm using firestore on angular but it is SSR (universal), I'm using firestore for client or server ?
I'm using firestore for client but I'm rendering it on server, what is this call ?
@hiepxanh that'd depend on where the code will run, so I think you'll need to import two different projects for firebase:
use firebase-js-sdk for client code (second example https://github.com/firebase/firebase-js-sdk/issues/303#issuecomment-344106384) and use firebase-admin for server-side code (third example).
oh my god, how can I putfirebase-admin in my angular component without angularfire2, that really a bad news. :(
this is really a serious problem if you have a production app
Same problem with my code also. In my case nodejs service needs to be client.
Hey guys thanks so much for your interest in firestore! I'm going to close this in favor of #221 as this is a known issue. Additionally you can feel free to go thumbs up #319 which is the fix!
thanks god, good to know you are fixing this I love this @jshcrowthe
same problem here using Firebase SDK version: 4.6.2 and firestore 4.6.1
(running server side)
import firebase from 'firebase/app'
import 'firebase/firestore'
look like he still does not finish that fix
Firestore (4.6.1) 2017-11-26T14:28:26.397Z: INTERNAL UNHANDLED ERROR: Error: Failed to fetch file
node_modules/protobufjs/dist/protobuf.js:5164:30
Im still experiencing this, with some queries (others work)
"firebase": "^4.7.0",
I am doing a WHERE
db.collection('orders')
.where('token', '==', token)
.get()
Most helpful comment
I ran into this problem because:
I fixed it after finding it in Node docs on https://cloud.google.com/firestore/docs/quickstart