Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Channel credentials must be a ChannelCredentials object when creating CloudTasksClient #92

Open
vrayco opened this issue Nov 7, 2023 · 3 comments

Comments

@vrayco
Copy link

vrayco commented Nov 7, 2023

I'm encountering the same problem as detailed in this GitHub issue: #77. Despite attempting the suggested workaround of aligning the @grpc/grpc-js version, the issue persists.

The error message I'm receiving is:

TypeError: Channel credentials must be a ChannelCredentials object at new ChannelImplementation

This error arises when executing the following code:

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

The versions I'm using are:

  • Npm dependency: @google-cloud/tasks: 4.0.1
  • Docker image: cloud-tasks-emulator: 1.2.0
@stfsy
Copy link

stfsy commented Feb 10, 2024

@vrayco I came across the same error

     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(),
});

I am using "@google-cloud/tasks": "^5.0.0"

stfsy added a commit to stfsy/cloud-tasks-emulator that referenced this issue Feb 10, 2024
@stfsy
Copy link

stfsy commented Feb 10, 2024

Here's a PR that updates the README #96

@dzivoing
Copy link

dzivoing commented Feb 16, 2024

@stfsy It compiles but i still get build error Error: Dynamic require of "@grpc/grpc-js" is not supported

UPDATE: new version of cloud tasks available "@google-cloud/tasks": "^5.1.0", works after update

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

No branches or pull requests

3 participants