Skip to content

Conversation

@stfsy
Copy link

@stfsy stfsy commented Feb 10, 2024

Fixes the following error when connecting to the emulator with "@google-cloud/tasks": "^5.0.0". It's not an issue with the emulator, but Google modules got updated, and the NodeJS example was out of date.

     TypeError: Channel credentials must be a ChannelCredentials object
      at new ChannelImplementation (node_modules\google-gax\node_modules\@grpc\grpc-js\build\src\channel.js:29:19)
      at new Client (node_modules\google-gax\node_modules\@grpc\grpc-js\build\src\client.js:65:36)
      at new ServiceClientImpl (node_modules\google-gax\node_modules\@grpc\grpc-js\build\src\make-client.js:58:5)
      at GrpcClient.createStub (node_modules\google-gax\build\src\grpc.js:345:22)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

The root cause is that in node_modules\google-gax\node_modules\@grpc\grpc-js\build\src\channel.js:29:19 the credentials object is checked to be an instance of google-gax/ChannelCredentials

However, in the README of this repository, the @grpc/grpc-js library is used to create the CredentialsObject.

import { credentials } from '@grpc/grpc-js';

const client = new CloudTasksClient({
  port: 8123,
  servicePath: 'localhost',
  sslCreds: credentials.createInsecure(),
});

Thus, the check in node_modules\google-gax\node_modules\@grpc\grpc-js\build\src\channel.js:29:19 fails because the given credentials object has a different prototype hierarchy.

I fixed it by using ChannelCredentials from google-gax module. No need to install or pin any dependency versions.

import { ChannelCredentials } from 'google-gax';

const client = new CloudTasksClient({
  port: 8123,
  servicePath: 'localhost',
  sslCreds: ChannelCredentials.createInsecure(),
});

@FezVrasta
Copy link

FezVrasta commented Aug 6, 2024

I think this changed again, it's giving me this error even though I have been using google-gax for a few months already

I had to use @grpc/grpc-js now, not after having ran yarn dedupe to ensure a single instance was in my node_modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants