Firebase Emulator Error: Channel credentials must be a ChannelCredentials object
See original GitHub issue[REQUIRED] Environment info
firebase-tools: 8.2.0 Platform: macOS
[REQUIRED] Test case
index.js
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
const DEBUG = true;
function markUserUpdated(userId) {
return new Promise((resolve, reject) => {
admin.firestore().doc(`users/${userId}`).update({ dbUpdated: new Date() })
.then(() => {
if (DEBUG) console.log('User successfully marked Updated', userId);
resolve();
})
.catch(e => reject(e));
});
}
exports.writeContact = functions.firestore
.document('users/{userId}/contacts/{contactId}')
.onWrite((doc, context) => {
const { userId } = context.params;
return markUserUpdated(userId);
});
[REQUIRED] Steps to reproduce
Run the emulator (functions & firestore) with this code. Modify a contact in firestore.
[REQUIRED] Expected behavior
The users/${userId}
doc should be updated and you should see a User successfully marked Updated
in the console.
[REQUIRED] Actual behavior
i functions: Beginning execution of "writeContact"
⚠ functions: TypeError: Channel credentials must be a ChannelCredentials object
at new ChannelImplementation (/Users/pitouli/Documents/GIT/my-app/functions/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/channel.js:65:19)
at new Client (/Users/pitouli/Documents/GIT/my-app/functions/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client.js:57:36)
at new ServiceClientImpl (/Users/pitouli/Documents/GIT/my-app/functions/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/make-client.js:49:5)
at GrpcClient.createStub (/Users/pitouli/Documents/GIT/my-app/functions/node_modules/google-gax/build/src/grpc.js:220:22)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
⚠ Your function was killed because it raised an unhandled error.
Additional notes
If I replace the function markUserUpdated by the following one, then the error is not thrown.
function markUserUpdated(userId) {
return Promise.resolve();
}
Note also that the datas are perfectly loaded from Firestore into the app, so the Firestore Emulator is running normallly.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Firebase Emulator Error: Channel credentials must be a ...
Hi @Pitouli this documentation here indicates how you need to connect your emulator and how the ChannelCredentials is needed and configurated.
Read more >Channel credentials must be a ChannelCredentials object ...
Hello I am new to node red and I encountered this error : "TypeError: Channel credentials must be a ChannelCredentials object " Here...
Read more >Connect your app to the Authentication Emulator - Firebase
For security reasons, the Authentication emulator issues unsigned ID tokens, which are only accepted by other Firebase emulators, or the Firebase Admin SDK ......
Read more >Authentication - gRPC
Channel credentials, which are attached to a Channel , such as SSL credentials. ... Create a default SSL ChannelCredentials object. auto ...
Read more >.NET client library | Google Cloud
To connect to the Firestore Emulator, you need to: Connect to the emulator endpoint; Use ChannelCredentials.Insecure as the channel credentials ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
OK, I’ve solved it myself. Just update firebase-admin to 9.0.0
npm install firebase-admin@latest
@Pitouli glad you fixed it! This error can happen when you have multiple versions of gRPC libraries in your node_modules. gRPC has a C++ implementation and sometimes passing objects (like Credentials) between versions does not work.
The good news is that almost all of Google’s Node.js libraries have moved to
grpc-js
which is a pure JS implementation so eventually this kind of error should disappear.