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: channelCredentials._equals is not a function #834

Closed
davemason-ladbible opened this issue Dec 5, 2019 · 9 comments
Closed

TypeError: channelCredentials._equals is not a function #834

davemason-ladbible opened this issue Dec 5, 2019 · 9 comments
Assignees
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@davemason-ladbible
Copy link

This issue occurs on versions 1.1.2 and later.

When attempting to publish a message to the emulator, I'm getting the following error:

TypeError: channelCredentials._equals is not a function

Function to re-create error:

const pub = async (topicName, data) => {
  const options = {
    keyFilename,
    projectId
  };
  if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
    options.apiEndpoint = 'emulator:8085';
  }
  const pubsub = new PubSub(options);
  const stringifiedData = JSON.stringify(data);
  const dataBuffer = await Buffer.from(stringifiedData);

  const topic = `projects/${projectId}/topics/${topicName}`;

  return pubsub
    .topic(topic)
    .publish(dataBuffer)
    .then((response) => {
      logger.info('Message published.', response);
      return {
        success: true
      };
    })
    .catch((error) => {
      logger.error('Failed to publish topic', error);
      return {
        success: false
      };
    });
};

Dockerfile of emulator:

FROM google/cloud-sdk:alpine

LABEL maintainer="LADbible Group"

RUN apk --update add openjdk7-jre
RUN gcloud components install --quiet beta pubsub-emulator
RUN gcloud components update
RUN mkdir -p /var/pubsub

VOLUME /var/pubsub

EXPOSE 8085

CMD [ "gcloud", "beta", "emulators", "pubsub", "start", "--data-dir=/var/pubsub", "--host-port=0.0.0.0:8085", "--log-http", "--verbosity=debug", "--user-output-enabled" ]

Environment details

  • OS: alpine
  • Node.js version: 10.15.0
  • npm version: 6.5.0
  • @google-cloud/pubsub version: 1.1.2+
@callmehiphop callmehiphop added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Dec 5, 2019
@callmehiphop
Copy link
Contributor

@davemason-ladbible thanks for the write up! Any chance you could provide us with a stack trace?

@davemason-ladbible
Copy link
Author

@callmehiphop Sure, here you are:

TypeError: channelCredentials._equals is not a function
          at SubchannelPool.getOrCreateSubchannel (/app/node_modules/google-gax/node_modules/@grpc/grpc-js/src/subchannel-pool.ts:132:32)
          at Object.createSubchannel (/app/node_modules/google-gax/node_modules/@grpc/grpc-js/src/channel.ts:139:36)
          at Object.createSubchannel (/app/node_modules/google-gax/node_modules/@grpc/grpc-js/src/resolving-load-balancer.ts:249:42)
          at subchannels.latestAddressList.map.address (/app/node_modules/google-gax/node_modules/@grpc/grpc-js/src/load-balancer-pick-first.ts:336:33)
          at Array.map (<anonymous>)
          at PickFirstLoadBalancer.connectToAddressList (/app/node_modules/google-gax/node_modules/@grpc/grpc-js/src/load-balancer-pick-first.ts:335:47)
          at PickFirstLoadBalancer.updateAddressList (/app/node_modules/google-gax/node_modules/@grpc/grpc-js/src/load-balancer-pick-first.ts:386:12)
          at Object.onSuccessfulResolution (/app/node_modules/google-gax/node_modules/@grpc/grpc-js/src/resolving-load-balancer.ts:210:34)
          at pendingResultPromise.then (/app/node_modules/google-gax/node_modules/@grpc/grpc-js/src/resolver-dns.ts:269:25)

@callmehiphop
Copy link
Contributor

Interesting, @murgatroid99 any thoughts on this?

@murgatroid99
Copy link

My best guess from that error is that a Client or Channel is being created with a bad channelCredentials argument. It could be some other kind of object, or a ChannelCredentials object from the grpc library or an older version of @grpc/grpc-js. I don't immediately see anything in that code that would cause that.

@kbariotis
Copy link

kbariotis commented Jan 13, 2020

Found the same when attempting to connect to the emulator. Latest version of both the emulator and this library.

@willianw
Copy link

Found the same when attempting to create a new subscription wihtin the emulator. Topic creation is ok. Versions:

@google-cloud-label-sync google-cloud-label-sync bot added the api: pubsub Issues related to the googleapis/nodejs-pubsub API. label Jan 30, 2020
@feywind
Copy link
Collaborator

feywind commented May 5, 2020

I'm going to put this on my list of stuff to retry shortly. I suspect some changes have happened to the emulator itself, because some of the problems I've tried to reproduce weren't happening for me. Also grpc-js has changed a lot. I see that some are using gRPC C++, though, so grpc-js updates wouldn't help with that.

@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Jun 2, 2020
@meredithslota
Copy link
Contributor

@feywind If the issue isn't resolved with the new version of grpc-js (and it's still an issue with the emulator) let's kick it to @kamalaboulhosn for guidance on ownership.

@feywind
Copy link
Collaborator

feywind commented Jun 25, 2020

I finally got a chance to try this out myself. I did have to make a few tweaks to make it works, so maybe this will help.

This is my Dockerfile, based on the original, but with an updated openjdk:

FROM google/cloud-sdk:alpine

RUN apk --update add openjdk11-jre-headless
RUN gcloud components install --quiet beta pubsub-emulator
RUN gcloud components update
RUN mkdir -p /var/pubsub

VOLUME /var/pubsub

EXPOSE 8085

CMD [ "gcloud", "beta", "emulators", "pubsub", "start", "--data-dir=/var/pubsub", "--host-port=0.0.0.0:8085", "--log-http", "--verbosity=debug", "--user-output-enabled" ]

This fixed a Java exception in the emulator for not finding the Duration class.

This is the sample code:

const PubSub = require('@google-cloud/pubsub').PubSub;

const pub = async (topicName, data) => {
  const options = {
    projectId: 'testproject',
    apiEndpoint: 'localhost:8085'
  };
  const pubsub = new PubSub(options);
  const stringifiedData = JSON.stringify(data);
  const dataBuffer = await Buffer.from(stringifiedData);

  const topicId = `projects/${options.projectId}/topics/${topicName}`;

  const topic = pubsub.topic(topicId);
  const exists = await topic.exists();
  if (!exists[0]) {
    await topic.create();
    console.log('created topic');
  }

  let sub = pubsub.subscription('testsub');
  const subExists = await sub.exists();
  if (!subExists[0]) {
    await topic.createSubscription('testsub');
    console.log('created sub');
    sub = topic.subscription('testsub');
  }

  const receivePromise = new Promise(r => {
    sub.on('message', message => {
      console.log('Message received', message.data.toString());
      message.ack();
      r();
    });
  });

  const response = await topic.publish(dataBuffer);
  console.log('Message published', response);

  await receivePromise;
};

pub('testtopic2', { test: 'test' }).then(() => {
  console.log('Exiting');
  process.exit(0);
}).catch(e => {
  console.error('Error', e);
});

This is the package.json:

{
    "name": "example",
    "version": "1.0.0",
    "description": "",
    "dependencies": {
        "@google-cloud/pubsub": "^2.0.0"
    }
}

And I'm getting this output:

Message published 4
Message received {"test":"test"}
Exiting

So I think this has been fixed by subsequent grpc updates or other changes. @willianw Your subscriber issue might be fixed by updating the JDK in the Docker image?

Please feel free to re-open if there are still problems!

@feywind feywind removed the 🚨 This issue needs some love. label Jun 25, 2020
@feywind feywind closed this as completed Jun 25, 2020
feywind pushed a commit to feywind/nodejs-pubsub that referenced this issue Nov 12, 2024
…googleapis#834)

* Moving API reference snippets and renaming region tags to not conflict with documentation snippets

* fix mismatched tags, fix mixed backups files

* fix quickstart tag

* linkenator fix
feywind pushed a commit to feywind/nodejs-pubsub that referenced this issue Nov 12, 2024
🤖 I have created a release \*beep\* \*boop\*
---
## [3.3.0](https://www.github.com/googleapis/nodejs-bigtable/compare/v3.2.0...v3.3.0) (2021-03-08)


### Features

* add CMEK fields ([googleapis#845](https://www.github.com/googleapis/nodejs-bigtable/issues/845)) ([0381fb7](https://www.github.com/googleapis/nodejs-bigtable/commit/0381fb7da68492b85f8a3359d5fb97ca4898810e))
* introduce style enumeration ([googleapis#833](https://www.github.com/googleapis/nodejs-bigtable/issues/833)) ([99b7617](https://www.github.com/googleapis/nodejs-bigtable/commit/99b7617e215126fc36ef3c3ebefb244e0d8d2242))
* **protos:** update BigtableTableAdmin GetIamPolicy, change DeleteAppProfileRequest.ignore_warnings to REQUIRED ([59a0d26](https://www.github.com/googleapis/nodejs-bigtable/commit/59a0d269d5196991dd395e671d7d5f54ce449005))


### Bug Fixes

* **browser:** check for fetch on window ([googleapis#824](https://www.github.com/googleapis/nodejs-bigtable/issues/824)) ([a38cbcc](https://www.github.com/googleapis/nodejs-bigtable/commit/a38cbcca1660bc40fe137acb973bf62f3c55754e))
* Renaming region tags to not conflict with documentation snippets ([googleapis#834](https://www.github.com/googleapis/nodejs-bigtable/issues/834)) ([5d3e8f7](https://www.github.com/googleapis/nodejs-bigtable/commit/5d3e8f721c2a32a33bf41baa1ed237fb90f7cbd6))
* **retry:** restore grpc_service_config for CreateBackup and RestoreTable ([googleapis#851](https://www.github.com/googleapis/nodejs-bigtable/issues/851)) ([3ff2828](https://www.github.com/googleapis/nodejs-bigtable/commit/3ff282855f4f9a52a89bca8d087c1423e71bd7c6))
* set keepalive configuration ([googleapis#836](https://www.github.com/googleapis/nodejs-bigtable/issues/836)) ([8105dea](https://www.github.com/googleapis/nodejs-bigtable/commit/8105dea272de44e69915d3e62e5b5add106b54cb))


---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

8 participants